Good one. This talks about just the Redis as standalone cache. How about making use of Redis along with database like MySQL? so all the CRUD operations will have one more element of adding/updating/deleting the actual data from database based on how Redis performs.
Great video! A very good example to get a first impressin on Spring, Redis and Rest combined at the right level of difficulty for me. A would like to see a similar example/examples with Spring Cloud Dataflow and Kafka or RabbitMQ.
could help to explain an example of a transaction in a distributed system using distributed Redis, ex: cart created, item added and when we add 2nd item we do not know, which replica of APP handle the 2nd scan and how can distributed cache help us
Hi, is redis necesarily used with jpa? because the way data is stored/retrieved/deleted/updated seems alike as jpa. is it possible to use redis with other data action type(such as mybatis. jpa will be faster, so the choice will be jpa, but I wonder why redis is always used with jpa)?
what is the difference between doing the crud operations in this way and doing crud operation using normal spring data jpa where model objects are annotated with RedisHash?
Hi, I implemented Spring redis and REDIS server I am running docker image, and port is mapped to local port. docker run -p 6379:6379 redis but when I run the application, I am getting the following error 2019-01-28 18:58:22.285 ERROR 49588 --- [nio-8081-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool] with root cause
Nice explanation. Just one question, can I create the beans of 'JedisConnectionFactory' and 'RedisTemplate()' in a configuration class file. I mean, if i will create a class called 'JedisConfiguration' and apply '@Configuration' annotation there and declare all my Beans in there ? Will it be a good choice ?
Hi Tech Primers, wonderful video, thoroughly enjoyed it. i have a question though, this is using spring data redis to store in memory database, but what if i want to use JPA along with this? such that when a request is made it should first search in the redis cache, if not found then hit the persistence ?
Can I lock the key? Like when I am query or handle some certain key's value, this key can not be reached by another operation. So basically can i add a lock on the key but not the whole redis process. If can how do you do it then?
i am able to post data using the code , but while fetching all values from redis using the key "USER" its not showing any data , but get "rest/user/all" is working fine .. any idea ? 127.0.0.1:6379> KEYS * 1) "\xac\xed\x00\x05t\x00\x04USER" 127.0.0.1:6379> HGETALL USER (empty array)
Use keys * command to know all the keys in the redis and the key would look weird, because generally Jedis makes the key of hash type so copy that key and type HGETALL it will display all the java objects of hash type
How did it connect to reddis, you have not provided any connection in application.properties to your local reddis, can someone please explain this, how the connection happened to reddis, we generally provide connection in case of MySQL through application.properties but in this case it didn't happen, please help.
Thanks for the Tutorial. Suppose we have a portal with Shopping Cart. Guest users, without login, can add products to their Shopping Cart. If we save the user's shopping cart to Redis, how to differentiate which Cart belongs to which user. Is there a way this can be done with JSESSIONID or something similar?
Thanks for the wonderful video. A crisp and clear introduction to the topic. Just what I needed before starting off on a new project. One suggestion .. can you please crop off a few seconds of the coughing sound in the video. It is a simple task on the UA-cam studio.
Can we configure the cache size and the cache time limit to invalidate the cache without restarting the redis server similar to how we configure using ehcache provider?
2018-12-29 13:55:39.459 INFO 4652 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2018-12-29 13:55:39.591 INFO 4652 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2018-12-29 13:55:39.621 INFO 4652 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.repository.ArticleRepository. 2018-12-29 13:55:39.625 INFO 4652 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.repository.CategoryRepository. 2018-12-29 13:55:39.626 INFO 4652 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.repository.UserAddressRepository. 2018-12-29 13:55:39.627 INFO 4652 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.repository.UserRepository.
@Ajay very informative video. I have got one doubt from where the data is coming i.e. from where are you reading the Name, Id ("1, Peter" , "2, Ryan") and storing it further in Redis. i ts kind of a silly question but if you can guide me here. TIA
Hi Peter, i am getting the output like {"2":{"id":"2","name":"surya","salary":20000},"1":{"id":"1","name":"nagendra","salary":20000}}. where im doing mistake.Suggest me to get output like your example.
Hi Team, Can you please share sample code of how to use using Mysql and Redis as a secondary cache integration with HashOps using Spring Boot? It will be helpful for many students.
I have done the same, check the below code: public Article findArtilcleById(String articleId) throws IOException { Optional id = Optional.of((Long) (Long.valueOf(String.valueOf(articleId)))); try{ //To check if data is in cache or not if(!hashOperations.hasKey(key, articleId)) { logger.info("Yes Data is not in the cache, add it in the cache now."); //Getting data from database Article a = articleRepository.findById(id); //Storing data from database to cache hashOperations.put(key, String.valueOf(a.getId()), a); return a; } }catch (Exception e){ System.out.println(" "+e.getMessage()); } // Returning data from cahce if data is in the cache. Article article = gson.fromJson(String.valueOf(hashOperations.get(key, articleId)), Article.class); logger.info(("Getting it from cache")); return article; }
Hi, i am really liking your Tech Videos, thanks a lot for the videos :) could you help me with Distributed Cache please, i am not getting references for this. One server with multiple clients accessing same cache, clients may be on same server or different server.
Connecting with host and password: @Bean JedisConnectionFactory jedisConnectionFactory() { RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration("192.168.1.51", 6379); redisStandaloneConfiguration.setPassword(RedisPassword.of("yourRedisPasswordIfAny")); return new JedisConnectionFactory(redisStandaloneConfiguration); }
I apolozise, in the previous comment on redis vedio i asked for java implementation, got it here, good work. Thanks
thanks for taking the time to explain redis on springboot. Much appreciated.
Awesome video. Crisp and to the point
Nice explanation . Thank you
Good one. This talks about just the Redis as standalone cache. How about making use of Redis along with database like MySQL? so all the CRUD operations will have one more element of adding/updating/deleting the actual data from database based on how Redis performs.
Great video! A very good example to get a first impressin on Spring, Redis and Rest combined at the right level of difficulty for me.
A would like to see a similar example/examples with Spring Cloud Dataflow and Kafka or RabbitMQ.
sure. will doo
Correct me if I’m wrong, did you do the @Postmapping part inside the URL bar? Thanks. 👍
could help to explain an example of a transaction in a distributed system using distributed Redis, ex: cart created, item added and when we add 2nd item we do not know, which replica of APP handle the 2nd scan and how can distributed cache help us
Thanks for this good demo. Helped me to kick start with Redis - Spring Boot
Hi, is redis necesarily used with jpa? because the way data is stored/retrieved/deleted/updated seems alike as jpa. is it possible to use redis with other data action type(such as mybatis. jpa will be faster, so the choice will be jpa, but I wonder why redis is always used with jpa)?
Great! Just have a question though, How you made connection to Redis running on some different port, How did Spring came to know about the same?
Good indeed, Can you have a tutorial for microservcie session handling? perhaps using redis
How to do a mass insertion in redis , I have a databse in MySql and i want it to add it to Redis Sever. Any method to do it so?
very nice explantion, if possible can u provide information , if redis cache server is running on different remote server ,so how to use that ?
Very well explained.
Thanks :)
Awesome video for beginners
An example of redis implemented along side of postgresql would be really helpful
sure michael, will do that soon
Here you have stored data directly to redis what if we want to add to data to oracle db with that maintain cache in redis
what is the difference between doing the crud operations in this way and doing crud operation using normal spring data jpa where model objects are annotated with RedisHash?
Hi,
I implemented Spring redis and REDIS server I am running docker image, and port is mapped to local port.
docker run -p 6379:6379 redis
but when I run the application, I am getting the following error
2019-01-28 18:58:22.285 ERROR 49588 --- [nio-8081-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool] with root cause
Thanks for the video.. I have doubt... You have mentioned that Redis doesn't provide any repository interface.. Why not used CrudRepository?
bro, you're awesome. thank you soo much for your efforts. Appreciate it 💙💙💙
Nice explanation.
Just one question, can I create the beans of 'JedisConnectionFactory' and 'RedisTemplate()' in a configuration class file.
I mean, if i will create a class called 'JedisConfiguration' and apply '@Configuration' annotation there and declare all my Beans in there ?
Will it be a good choice ?
Good comprehensive tutorial... Thank you...
Can we connect to the aws elastic cache (redis) locally ?
Can u post video on authentication & Authorization with redis for multiple services. Thanks
Hi Tech Primers,
wonderful video, thoroughly enjoyed it.
i have a question though, this is using spring data redis to store in memory database, but what if i want to use JPA along with this?
such that when a request is made it should first search in the redis cache, if not found then hit the persistence ?
Thank you so much for this tutorial it was very helpful. Can you do a tutorial about user registration with redis?
I notice you didn't use @Autowired in Controller and in Impl class but still this example run - how ?
Can I lock the key? Like when I am query or handle some certain key's value, this key can not be reached by another operation. So basically can i add a lock on the key but not the whole redis process. If can how do you do it then?
i am able to post data using the code , but while fetching all values from redis using the key "USER" its not showing any data , but get "rest/user/all" is working fine .. any idea ?
127.0.0.1:6379> KEYS *
1) "\xac\xed\x00\x05t\x00\x04USER"
127.0.0.1:6379> HGETALL USER
(empty array)
Is there an example explaining Redis using the Lettuce client?
Thankyou for the very insightful tutorial !
It's helpful video thanks u so much sir
can you tell how to see these inserted values in redis command line interface ??
Use keys * command to know all the keys in the redis and the key would look weird, because generally Jedis makes the key of hash type so copy that key and type HGETALL it will display all the java objects of hash type
nice and very helpful video
How did it connect to reddis, you have not provided any connection in application.properties to your local reddis, can someone please explain this, how the connection happened to reddis, we generally provide connection in case of MySQL through application.properties but in this case it didn't happen, please help.
Why use opsforhash over opsforvalue?
Great video..
Hi Ajay,
Thanks for Great Video.
How can I use redis as a distributed cache?
how to inject redisTemplate by only using the application.properties ??
Great video!
How do i set expiry / or time to live for User objects while saving ?
Thanks for the Tutorial. Suppose we have a portal with Shopping Cart. Guest users, without login, can add products to their Shopping Cart. If we save the user's shopping cart to Redis, how to differentiate which Cart belongs to which user. Is there a way this can be done with JSESSIONID or something similar?
Please add videos for redis sentinel mode with lettuce client
Thanks very nice explanation
How to set TTL here?
How to store data from zuul filter to redis. Thanks
For every repository we need to create RedisTemplate? Like in your case you had only user repository so you created RedisTemplate
you have any example how to store jwt token into Redis cache
You helped me a lot!
Thanks for the wonderful video. A crisp and clear introduction to the topic. Just what I needed before starting off on a new project. One suggestion .. can you please crop off a few seconds of the coughing sound in the video. It is a simple task on the UA-cam studio.
Thank you for the tutorial but if i want to do a post call how to do that
jedis pool config is required how to manage it?
How to see the results in redis server
Can u Post an example on junit how to write junit test case for controller
video coming in few minutes
Awesome bro :) I really liked this video.. Very Informative.. Thanks :)
Can you please make a video on Redis Pub-Sub using Spring Boot? Thanks in advance
Did I miss the Redis Configuraiton in Spring boot Application ?, I saw you created JedisConnectionFactory and assigned to RedisTemplate.
Please make a video on spring boot with jwt authentication using redis
Can we configure the cache size and the cache time limit to invalidate the cache without restarting the redis server similar to how we configure using ehcache provider?
Yes, you can do both without restarting the Redis server
Thanks it was quite helpful.Is there a way i could use findByIdAndnameNot in Springdata redis?
great question!
why did'nt you use @cacheable?
very helpful tutorial
Why did not we autowired the redisTemplate in Repository ?
Hi bro can u tell me how to invalidate the session.... In redis...
could you please show us.How to deploy this example on PCF cloud
you can check other videos on PCF. I have done them.
thanks for your job, bro)
a very good tutorial I was wondering how to implement redis with mongodb if you have any idea it will be great thanks
Awesome Dude
2018-12-29 13:55:39.459 INFO 4652 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2018-12-29 13:55:39.591 INFO 4652 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2018-12-29 13:55:39.621 INFO 4652 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.repository.ArticleRepository.
2018-12-29 13:55:39.625 INFO 4652 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.repository.CategoryRepository.
2018-12-29 13:55:39.626 INFO 4652 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.repository.UserAddressRepository.
2018-12-29 13:55:39.627 INFO 4652 --- [ restartedMain] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.repository.UserRepository.
As I mentioned Please guide me how to resolve this
Dont we need to start redish server separately or it is embedded ?
It's separate
@Ajay very informative video. I have got one doubt from where the data is coming i.e. from where are you reading the Name, Id ("1, Peter" , "2, Ryan") and storing it further in Redis. i ts kind of a silly question but if you can guide me here. TIA
hi ruchita, the values are created via REST endpoints (/rest/user/update)
Super video bro😀...
my pleasure gobi
Tech Primers can we use redis as a normal database
+gobi nath yes you can. But you wont have great SQL client lile tools for querying redis
Tech Primers ok... Thank you very much
Is it same for redis search also ?
what is same? I did not get your question prakash
Thanks.
please make videos on spring boot
Can anyone have any information on redis pipeline in spring boot?
Hello one more examples with MySQL database using with redis how to implement MySQL and hibernate...
thank you... it is working fine. i did it..
Hi Peter,
i am getting the output like {"2":{"id":"2","name":"surya","salary":20000},"1":{"id":"1","name":"nagendra","salary":20000}}.
where im doing mistake.Suggest me to get output like your example.
What's wrong here. Is it the order of elements?
Thank you so much for sharing. It is great!
My pleasure Jakson. Glad that was useful
It does. Thank you.
Hi Team,
Can you please share sample code of how to use using Mysql and Redis as a secondary cache integration with HashOps using Spring Boot?
It will be helpful for many students.
I have done the same, check the below code:
public Article findArtilcleById(String articleId) throws IOException {
Optional id = Optional.of((Long) (Long.valueOf(String.valueOf(articleId))));
try{
//To check if data is in cache or not
if(!hashOperations.hasKey(key, articleId)) {
logger.info("Yes Data is not in the cache, add it in the cache now.");
//Getting data from database
Article a = articleRepository.findById(id);
//Storing data from database to cache
hashOperations.put(key, String.valueOf(a.getId()), a);
return a;
}
}catch (Exception e){
System.out.println(" "+e.getMessage());
}
// Returning data from cahce if data is in the cache.
Article article = gson.fromJson(String.valueOf(hashOperations.get(key, articleId)), Article.class);
logger.info(("Getting it from cache"));
return article;
}
Simple annotations are dere , easy
Thanks. Exect this is nessary for interview.
Thx!
ty
hi getting this exception
Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig
Respect ++ !
Hi, i am really liking your Tech Videos, thanks a lot for the videos :) could you help me with Distributed Cache please, i am not getting references for this. One server with multiple clients accessing same cache, clients may be on same server or different server.
Why didn't you use @RedisHash ?
@RedisHash was introduced post Spring data redis 1.7
Cool
Spring Data Redis in Spring Boot Example | Tech Primers
"sping" boot in thumbnail
Connecting with host and password:
@Bean
JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration("192.168.1.51",
6379);
redisStandaloneConfiguration.setPassword(RedisPassword.of("yourRedisPasswordIfAny"));
return new JedisConnectionFactory(redisStandaloneConfiguration);
}
for beginners its really hard to understand
bro hy , redis wtf
How can i use hateoas and HAL in this project