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.
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 RU-vid studio.
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 ?
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)?
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
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?
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?
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?
@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
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
Thanks, It was lot Helpful. I am thinking about connecting springboot to AWS Elasticache Redis. Will this implementation work if I provide hostname and port number ?
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)
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.
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.
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
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?
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); }