Spring Boot | Spring Data Redis as Cache | @Cacheable | @CacheEvict | @CachePut | JavaTechie

Поділитися
Вставка
  • Опубліковано 15 жов 2024
  • This tutorial will guide you how to use Spring Data Redis as a cache to improve application performance
    #javatechie #Redis #SpringBoot
    Spring Data Redis as Database
    • Spring Boot | Spring D...
    GitHub:
    github.com/Jav...
    Blogs:
    / javatechie
    Facebook:
    / 919464521471923
    guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
    Disclaimer/Policy:
    --------------------------------
    Note : All uploaded content in this channel is mine and its not copied from any community , you are free to use source code from above mentioned GitHub account

КОМЕНТАРІ • 134

  • @harshitgupta2872
    @harshitgupta2872 2 роки тому +4

    Sir, where is the primary data database to store data in redis , you didn't connect to any data base (such as MongoDb) as primary database so that we use Redis as Cache

  • @swagatrath2256
    @swagatrath2256 3 місяці тому +1

    I have a little bit of confusion here..
    The DB being used is Redis and caching is being done at the application level.. which also is using Redis?
    How do you configure which cache mechanism to be used then?

  • @user-wc4zn7ew7t
    @user-wc4zn7ew7t 2 роки тому +5

    Thanks you @java techie, Your videos are very helpful for me. It made me learn Redis Basic in just few hours with example. thanks again appreciatable approach. 👍👌

  • @satyabatigoswami1735
    @satyabatigoswami1735 7 місяців тому +1

    Learnt so much from your videos. You are very good teacher and a very good person!! Thanks a lot🙏

  • @vivian1154
    @vivian1154 Рік тому +1

    Redis serves a cache purpose primarily here already I believe. the cacheable annotation is to make the method cacheable by conditions to Java in memory. Is my understanding correct?

  • @ihabson
    @ihabson Рік тому +6

    Thank you for the video. I’m a newbie when it comes to cache, so is it possible to give more information about it. Like where is the data stored ? I guess it’s in the RAM but which one ? And what happens if the data changes in the mean time ? Does it mean that applications can possibly get an obsolete « snapshot » of the database because of caching ? Is that where the TTL comes handy ? Or is the « record » deleted from the cache if it changes ? Thank you very much

    • @deeplife9654
      @deeplife9654 5 місяців тому

      Lolz. His video tutorials are for medium skilled developers to go to Advanced level

  • @divyamahesh9032
    @divyamahesh9032 7 місяців тому

    Hi basant
    I watched both the videos redis as db and redis as cache.In redis as cache video you are using redis as both db and cache . And also if we want we can replace db with any other one eg:oracle etc...
    Am i right???

  • @sasi2182
    @sasi2182 3 роки тому +2

    Where the cache data will be stored ...I think it’s in memory db... not stored in redis DB.....what if I have millions of records... will it stored in application itself??

    • @Javatechie
      @Javatechie  3 роки тому +1

      No it won't store in application .
      Always it store in in memory cache

    • @sasi2182
      @sasi2182 3 роки тому

      @@Javatechie no Basant it's storing in local only ,,,try with by up another instance of same application... Then if you hit request then it's going and hitting database

    • @phoneix24886
      @phoneix24886 3 роки тому

      @@sasi2182 Hi sasi, so when we use @Cacheable it is storing data in memory of the application right?

    • @phoneix24886
      @phoneix24886 3 роки тому

      @@sasi2182 My doubt just got clarified thanks to this gentleman - ua-cam.com/video/1iLy8m33FV8/v-deo.html

  • @gopisambasivarao5282
    @gopisambasivarao5282 Рік тому +1

    Appreciate your efforts Basant. God Bless you.😊🙏

  • @zuberdiwan8123
    @zuberdiwan8123 Рік тому +1

    Very Nice Tutorial sir...Very Well Explained...Thank You

  • @jewelchowdhury9752
    @jewelchowdhury9752 3 роки тому +1

    First of all, thank you very much, sir. I have a question. I want to build a micro-service based e-commerce web application. suppose, I have some services, like customer service, product service(only contain Title and description and the image & price fetches IMG & price from another IMG service & price service), order service, and cart service. In my product service, It is possible when I have static data. and I have tried it. But my question is how can I add a new product record (with all fields) from the admin service(admin panel) into the multiple services like IMG service, product service(Title and description), price service? Please make a video on how to add records into multiple services at a time?

    • @Javatechie
      @Javatechie  3 роки тому +1

      Yes we can share same data accros multiple service through Rest API call
      You can check my microservice first video from microservice playlist .you will get clarity on that

    • @jewelchowdhury9752
      @jewelchowdhury9752 3 роки тому

      @@Javatechie thank you sir

  • @govardhanmopada1235
    @govardhanmopada1235 3 роки тому +4

    Thank you for your videos...
    I learnt more from your videos.
    Very good explanation ❤️👌

  • @manishdadheech8440
    @manishdadheech8440 3 роки тому +2

    I have small doubt Basant... here you are just configured Redis template in Redis configuration file then using cachable to cache product .. Here how spring comes to know that it needs to use Redis DB to cache data. Normally we need to implement spring interface Cache and CacheManager Then how it is working internally.

    • @Javatechie
      @Javatechie  3 роки тому

      Because already we are using ResdisHasOps in our dao. Class and there we are persisting data into reddis server .

  • @veerraju8445
    @veerraju8445 2 місяці тому

    What is the type of cache used here,is it read through cache?

  • @sanketr6256
    @sanketr6256 11 місяців тому +1

    very nice video and thanks for the content Basant

  • @balamurali5127
    @balamurali5127 3 роки тому +1

    I am getting error as Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

    • @A2ZZ555
      @A2ZZ555 2 роки тому

      Bro resolve hua error apka

  • @arunprasadvs3452
    @arunprasadvs3452 Рік тому

    1.How is it implemented in application
    2.What functionalities in application utilizes caching
    3.How do you identify that a method uses caching from code
    kindly reply me

  • @fuadgafarov
    @fuadgafarov 2 роки тому +2

    Thanks, it will help in my career a lot. Great job. Keep going please.

  • @bhavanisankar71
    @bhavanisankar71 Рік тому

    Sir i applied cache for findAll() that time updated data not getting means after retrieving all data update and delete data not updating to findAll() getting previous data only how can i improve this problem

  • @KrishnaReddy-qb2jm
    @KrishnaReddy-qb2jm 3 роки тому +1

    when you say get data from db? is it redis client or some sql db? because i see productdao getting data from redis. @Cacheable caches local memory?

    • @phoneix24886
      @phoneix24886 3 роки тому

      I actually have the same question not clear here

  •  2 роки тому

    Excellent.. but how compiler knows that you are using redis by annotation only??

  • @hrajiv29
    @hrajiv29 2 роки тому +1

    Thanks for providing such a nice explanatory videos

  • @ankushmane2336
    @ankushmane2336 Рік тому

    Hi @Java Techie,
    I watch this video and used the same on my system but the @Cacheable and @CacheEvict functionality does not work for me.
    get records not cached into the cache.
    could you please help me?

    • @Javatechie
      @Javatechie  Рік тому

      It shouldn't be behaved like this.let me cross check and update you

  • @kvnagendra5354
    @kvnagendra5354 2 роки тому +1

    Sir when we have devtool dependency in pom.
    And when we call findbyid there its throwing classcast exception..

    • @Javatechie
      @Javatechie  2 роки тому

      findById now returning Optional please check it properly

  • @amansinha3629
    @amansinha3629 Рік тому +1

    How to specify key in the cacheable method if the method has no parameter?

  • @sudhirkk007
    @sudhirkk007 2 роки тому +1

    You explained every thing very well, But I can' see you redis connection details ?

    • @Javatechie
      @Javatechie  2 роки тому

      Buddy connection info mentioned in config class please check

  • @sudhirkk007
    @sudhirkk007 2 роки тому

    same code I trying with Azure redis its not working , getting jedis connection exception

  • @PriteshBhate
    @PriteshBhate 3 роки тому +1

    very helpful. Sir, what parameters we passed in @Cacheable . key is understood but doesn't understand value parameter. Can you please explain .

    • @Javatechie
      @Javatechie  3 роки тому

      You can pass conditional parameter in value

  • @ranjan098
    @ranjan098 6 місяців тому +2

    Hi Basant bhai, Great tutorial !!! . is it possible to use Database as some other database but not Redis DB, and use Redis Cache to communicate between db and cache ?

    • @Javatechie
      @Javatechie  6 місяців тому

      Yes it's possible but I need to check about configuration

    • @midhunma8875
      @midhunma8875 4 місяці тому

      Hi Please let me know if you found any useful tutorials in this

  • @RootAccess
    @RootAccess 2 роки тому +1

    What will happen if I have multiple instances of application running?

    • @Javatechie
      @Javatechie  2 роки тому

      Your request will always landed to a single instance

    • @RootAccess
      @RootAccess 2 роки тому

      @@Javatechie consider I have two instances running both instances cached value for key 1 then instance 1 receive delete request after that instance 2 receive get request what will i get then will instance 2 check database?

  • @sathiskumarp
    @sathiskumarp 2 роки тому +1

    Thanks for the video. I have an order service and payment service, based on the payment service response I have to commit the value to DB. So whether it is possible to maintain the update operation in cache as an intermediate and once the payment is confirmed we can commit to actual DB.

    • @Javatechie
      @Javatechie  2 роки тому

      No Satish cache will work behind the db. So if you update on db then it will reflect on cache not reverse

    • @sathiskumarp
      @sathiskumarp 2 роки тому

      @@Javatechie Thanks for your response

    • @SP-yh5op
      @SP-yh5op Рік тому

      Thanks for your making concepts easier. @Java Techie
      Is it good idea to have 1 utility micro service for Radis caching or having in all 10+ persist micro services configured with redis interactions. We have like 100+ micro services with Kafka streaming.

  • @mahmoudodeh3534
    @mahmoudodeh3534 3 роки тому +4

    Thank you for being teacher

  • @Harish.D-f1l
    @Harish.D-f1l Рік тому

    I am Getting Exception,
    org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection;

  • @r.kgupta2561
    @r.kgupta2561 Рік тому +1

    Hi Sir , I watched this video its great explanation, but i was looking for Something like Read Through ,Write Through and Asynchronous Caching, if there is some video or blogs can you please suggest me

  • @manirsg9641
    @manirsg9641 4 роки тому +1

    I am wondering that, how this caching working without redis instance? We can use redis docker image for this work

    • @Javatechie
      @Javatechie  4 роки тому +1

      Yes already I up my redis server , please checkout my previous tutorial.
      In config I provided host and port of reddis instance and up it .

  • @imshaggy619
    @imshaggy619 Рік тому +1

    How can I store the cached data into any file and get the data from that file when required in code

    • @Javatechie
      @Javatechie  Рік тому

      Then why do you need cache?

    • @imshaggy619
      @imshaggy619 Рік тому

      @@Javatechie it's a large number of values , big table. So what will be the easier approach to get those as needed without a DB hit everytime.
      Like a lookup service for the cache - lookup.getValue(key)

  • @aidataverse
    @aidataverse 3 роки тому +1

    very much useful appreciate your effort

  • @pushpamitdon
    @pushpamitdon 3 роки тому +1

    Informative video but I've a query. What is the difference between caching using @Cacheable and caching via RedisTemplate. Are these records not available in Redis DB if we cache via @Cacheable?

  • @yashpatel-qg3ic
    @yashpatel-qg3ic 2 роки тому

    hello @java techie , can you tell me how to do update method. I want to implement in my college project. so can you help me on this. Thankyou in advanced. If you help me in that it will be the great.

    • @yashpatel-qg3ic
      @yashpatel-qg3ic 2 роки тому

      i have searched like template.opsForHash(). (for update) I didnt find anything on that, If you help me, It will be the great. atleast which method should i use for update please.

    • @yashpatel-qg3ic
      @yashpatel-qg3ic 2 роки тому

      can you confirm it, it will be the same as create please.

  • @aneckumar5701
    @aneckumar5701 3 роки тому +1

    hello sir, how can i clear redis cache on booting the project , if not how can I clear cache manually?

  • @pamuletip5054
    @pamuletip5054 3 роки тому +1

    What is the maven dependencies that we have to keep for redis??

    • @Javatechie
      @Javatechie  3 роки тому +1

      Go to video description and checkout my GitHub link

  • @vinodkumarreddy7696
    @vinodkumarreddy7696 3 роки тому +1

    Thanks for the video.. Can we see cache data? and we can store it in a memory I mean local disk?

  • @satyabratasahoo967
    @satyabratasahoo967 3 роки тому +2

    Thank you Basant bhai, can you please explain more on the master slave implementation of redis?

  • @trilochanpanda8165
    @trilochanpanda8165 3 роки тому

    Could you plz explain this cache mechanism with jwt token, aslo with spring security, login and logout.

  • @phoneix24886
    @phoneix24886 3 роки тому

    I don't understand something. If Redis is itself a cache, and we are saving to redis, why use @Cacheable?

    • @phoneix24886
      @phoneix24886 3 роки тому

      Nevermin, use this link to get clarified - ua-cam.com/video/1iLy8m33FV8/v-deo.html

  • @abhireddy8164
    @abhireddy8164 4 роки тому +1

    Sir please do one video on how to establish a communication betweem two microservices by using message queues with one example..i.e.one microservice pass some data to another microservice to process it..like order microservice sends data to payments microservice..

    • @Javatechie
      @Javatechie  4 роки тому

      Already covered this so You could check my spring cloud stream or Kafka producer & Consumer video .

  • @jdbcspring6804
    @jdbcspring6804 3 роки тому

    hello, i have a question, when we cache every operation or any operation that we want what if there's changes happened in the database "update statment" in this case the data will fetch from the redis and they will took the oldest one "before the update ", can you please clarify about this ?

    • @TheLeony2
      @TheLeony2 3 роки тому

      yes, but you can use @CachePut to synchronize date with cache

    • @WajidAli-wk8je
      @WajidAli-wk8je 3 роки тому +1

      @@TheLeony2 Can you please give an example, I am trying but it does not update the list in the cache. I mean It is not updating the cache entry, after I call getall(I have cached previously) has same value as before.

  • @kks___
    @kks___ 4 роки тому +2

    Sir first of all Thank you so much for your All Video 🙏
    Sir a request to you please make a video on jwt token blacklisting before expires and refresh token please please it’s my humble request .

    • @Javatechie
      @Javatechie  4 роки тому +4

      Okay sure I will try this

  • @Entertainment_Zone2522
    @Entertainment_Zone2522 2 роки тому

    How can MySQL update data in real time in redis cache?

  • @rajeshg3570
    @rajeshg3570 3 роки тому

    Nice video but I don't see any reference to Redid here .. Did I miss anything ??

  • @mobinshah1
    @mobinshah1 3 роки тому +1

    You are the best. No doubt

  • @MrRnl2004
    @MrRnl2004 2 роки тому

    Thanks for this helpful tutorial. Can you have a tutorial how to setup your local redis? Thanks

  • @abhishekpatidar9903
    @abhishekpatidar9903 3 роки тому +1

    Can i use database as mysql and redis for caching, if yes then how?

  • @k.i.m.5506
    @k.i.m.5506 2 роки тому

    Hi friend, thanks for another great tutorial. One quick question -- how do you set up TTL with this solution?

  • @rexsam3134
    @rexsam3134 Рік тому

    Initial 3 minutes were there in other video and need not be repeated here. @Cachable is added only in fetch records.

  • @gauravk002
    @gauravk002 2 роки тому +1

    Again an excellent video from Java Techie..

  • @saurabhmarpadge7498
    @saurabhmarpadge7498 4 роки тому +1

    Nice video sir.
    Sir can you make a video on how to apply sharding in InMemory DB if it is possible .

  • @sandesh4063
    @sandesh4063 3 роки тому

    Nice video, one more thing I would like to know that how can we set expiry date to to cache, and how can we clear all keys from cache without deleting records from database?
    Thanks in advanced 🙏

  • @gursimransinghbhatiaa6131
    @gursimransinghbhatiaa6131 3 роки тому

    Can @cachaeble be used even in non-spring classes?

  • @Saravanan-lj9so
    @Saravanan-lj9so 4 роки тому +1

    This code is not working for me ..Getting a connection refused. Any one tried?

    • @Javatechie
      @Javatechie  4 роки тому +1

      You need to start your redis server , I already started but missed to mention while recording video .

    • @Saravanan-lj9so
      @Saravanan-lj9so 4 роки тому +1

      @@Javatechie Thanks.I will try

  • @mallikarjun-shurpali9698
    @mallikarjun-shurpali9698 Рік тому +1

    Thanks sir...

  • @CaponordRevHappy
    @CaponordRevHappy 3 роки тому +1

    Nice one! very helpful.

  • @nareshch6454
    @nareshch6454 6 місяців тому

    simple and great videos!

  • @yashrao7236
    @yashrao7236 3 роки тому +1

    Sir, is it possible to configure different Time To Live values for different cache values(endpoints)?

  • @johnvick8861
    @johnvick8861 Рік тому

    Is there any course you provide

  • @sadigepawan4710
    @sadigepawan4710 4 роки тому +1

    Hi basant could you please do video on file operations and kafka streams ??

    • @Javatechie
      @Javatechie  4 роки тому +1

      Could you please check out my spring cloud playlist

  • @simashpokharel6044
    @simashpokharel6044 2 роки тому

    Can you make a video on Spring boot + memcached ?

  • @shubhamkale5003
    @shubhamkale5003 2 роки тому

    Very good video Sir

  • @nikp7743
    @nikp7743 Рік тому +1

    Прикольно что индусы даже не стараются говорить без акцента)

  • @HoangDuyong-zl4jk
    @HoangDuyong-zl4jk 6 місяців тому

    could you please teach me how to insert data to database and redis

  • @techappleteja8564
    @techappleteja8564 3 роки тому

    it would be nice if show demonstrate "Product" hash with Relationships

  • @himanshanawarathna5931
    @himanshanawarathna5931 Рік тому +1

    Thank you !

  • @gajendrathakur4833
    @gajendrathakur4833 3 роки тому +1

    Thanks Sir

  • @vijayjumbad6074
    @vijayjumbad6074 2 місяці тому

    But where you config redis cache?

  • @arunpatel1619
    @arunpatel1619 Рік тому

    Create video on handling shared cache in spring boot microservices

  • @akaghachinaka5852
    @akaghachinaka5852 3 роки тому +1

    excellent! thanks.

  • @udaysurse5438
    @udaysurse5438 4 роки тому +1

    Nice

  • @devang007
    @devang007 3 роки тому +1

    Great video!!

  • @2RAJ21
    @2RAJ21 2 місяці тому

    Thank you

  • @curiouspragyan1938
    @curiouspragyan1938 3 роки тому

    How to implement redix connection pool logic

  • @TheTulunka
    @TheTulunka 2 роки тому +1

    i love you, java techie

  • @Dedeepya9
    @Dedeepya9 4 роки тому +1

    Thanks 👍

  • @sovansingh7937
    @sovansingh7937 4 роки тому +1

    sir make a video on spring-security saml

  • @othetai6297
    @othetai6297 4 роки тому +1

    video good :))

  • @hamzabouzidi2944
    @hamzabouzidi2944 2 роки тому

    we say the value not the balue :)

  • @arjunponti1483
    @arjunponti1483 3 роки тому

    Hi

  • @hamzabouzidi2944
    @hamzabouzidi2944 2 роки тому

    bro please learn to speak english we say cache not kece