Building a Cache with Upstash Redis in Next.js

Sdílet
Vložit
  • čas přidán 27. 08. 2024
  • In this video we'll cache expensive API calls in Redis within our getServerSideProps function.
    ---------- Course
    Want to go deeper with Next.js? Join me in my Next Level Next.js course where over 29 videos and 8 hours of content we'll build a full application from start to finish. We use TypeScript, GraphQL, Prisma, Apollo, Mapbox, Firebase and lots more. courses.leighh...
    ---------- Links
    Upstash - upstash.com/
    Source Code - github.com/lei...
    Starter Code - github.com/lei...
    ---------- Connect
    Join this channel - / @leighhalliday
    Join me on Discord - / discord

Komentáře • 41

  • @deathdefier45
    @deathdefier45 Před rokem

    The only time I really learn important typescript/javascript information is when it's explained here. Thanks for this amazing content!

  • @ji9306
    @ji9306 Před rokem

    🔥🔥🔥🔥🔥🔥 Worked perfectly!

  • @subhasarkar2420
    @subhasarkar2420 Před 3 lety

    I am really lucky that i found this channel, man you always cover important topics that most of the channel just skip.

  • @RawFatGod
    @RawFatGod Před 2 lety

    Awesome. I don't always watch the vids because I'm not into typescript yet, but it's always very useful and clear and easy to follow along. I actually built my first website off watching your headless CMS blog video.

  • @jayshah5695
    @jayshah5695 Před rokem

    kudos for Purchasing power parity!

  • @76Freeman
    @76Freeman Před 3 lety +1

    Thank you Leigh, very clear, straight to the point :)

  • @greensquarecinema
    @greensquarecinema Před rokem

    Fantastic, thank you!!

  • @atulsinghrajput9932
    @atulsinghrajput9932 Před 3 lety

    loud and clear thanks for this amazing tutorial

  • @jake1350
    @jake1350 Před 2 lety

    This video is phenomenal. Thank you.

  • @fardeenpanjwani9724
    @fardeenpanjwani9724 Před 3 lety +5

    Great video, as usual!
    BTW, you can use Promise for async functions that do not return anything :)

    • @leighhalliday
      @leighhalliday  Před 3 lety +1

      Haha I figured it out after shooting the video but by then it was too late! Thanks for the kind words!!

  • @manosmenexis3160
    @manosmenexis3160 Před 3 lety

    Always learning here. it's amazing!!! Thank you.

  • @dailymeow3283
    @dailymeow3283 Před 2 lety

    This api is great, thank you

  • @hbela1000
    @hbela1000 Před 2 lety

    Great video, thx.

  • @exponent42
    @exponent42 Před 3 lety

    love the way you teach

  • @Colstonewall
    @Colstonewall Před 3 lety

    Thanks Leigh!!

    • @leighhalliday
      @leighhalliday  Před 3 lety +1

      Hope it helped!!

    • @Colstonewall
      @Colstonewall Před 3 lety +1

      @@leighhalliday Of course it will help! Your stuff is always amazing, and more importantly, useful.

  • @letonik72
    @letonik72 Před 2 lety

    Спасибо за видео!

    • @leighhalliday
      @leighhalliday  Před 2 lety +2

      I had to use google translate for this hehe, but thank you!

  • @trevorkelley5397
    @trevorkelley5397 Před 2 lety

    you are so clutch

  • @Norfeldt
    @Norfeldt Před 3 lety

    You are amazing!

  • @osamajbnoni
    @osamajbnoni Před 2 lety

    Great video,
    what's the point of using redis when we cache using vercel caching technique ?

  • @Abdel-bw8qb
    @Abdel-bw8qb Před 3 lety

    Hey Thank you for the content ! Btw what is your vs code theme ?

  • @flagoon
    @flagoon Před 3 lety

    Nice tutorial, but I think I might now understand something. We are using Redis DB hosted on upstash, does this mean each time we visit a page, we have to make a call to upstash to check if value is preset? How is it different from calling out PPP endpoint to check the value?

    • @leighhalliday
      @leighhalliday  Před 3 lety +1

      Hey! Nope, you're not missing anything. The thesis is that Redis will be faster than the external API... you'd have to make a decision for yourself whether it is worth it for your situation, but it was also just an example that you can cache any value to avoid "expensive" calculations on each page request. Imagine inside of the fetcher function it is making 10 API requests which each take 300ms... that is 3 seconds compared to maybe just 100ms to Redis and back.

    • @leighhalliday
      @leighhalliday  Před 3 lety +2

      I had one more thought to add, since it's a very valid point. With Redis we can control where it is located, so if we put Next.js and Redis in the same cloud region, latency becomes a minimal concern, and in our control. When dealing with an external API, the location is out of our control so latency could fluctuate and become more of an issue.

    • @MrVoidfull
      @MrVoidfull Před 2 lety +1

      @@leighhalliday I think in this specific case, using a local Redis setup would have been ideal. That being said, one of the main advantages of caching is the fact that you are not actually calling the external API locally. External APIs are often paid, and having a caching setup will save you huge amounts of money when done properly. Using a local setup for Redis would still be ideal in that case, but the main purpose is saving money in that case.

  • @jeromealtariba7339
    @jeromealtariba7339 Před 3 lety

    hi, nickel! But I guess the fetcher should return a Promise not T (fetcher: () => Promise)

  • @Norfeldt
    @Norfeldt Před 3 lety

    Have you tried the redis pubsub with nextJS?

    • @leighhalliday
      @leighhalliday  Před 3 lety

      I have not... I've always wondered how that would work since Next.js is typically hosted serverless???

    • @Norfeldt
      @Norfeldt Před 3 lety

      @@leighhalliday I was hoping you knew. Been using firebase real-time database but have been curious to know if the real time experience could be archived with some clever redis

  • @evranfurkan
    @evranfurkan Před 3 lety

    Thank you