How to use Redis Caching for Incredible Performance

  Рет қаралды 48,053

Josh tried coding

Josh tried coding

Жыл бұрын

Caching database queries with Redis can be an incredible way to speed up your API responses. That will not only cost you less database quota but drastically improve user experience as well. Let's see you how can implement super fast caching for yourself!
My GitHub: github.com/joschan21
Upstash (not sponsored): upstash.com/
I wish you a lot of fun implementing caching and seeing the results for yourself. Let me know if you build something cool with it! Cheers

Пікірлер: 74
@crypt0nerd621
@crypt0nerd621 Жыл бұрын
This is very interesting and useful. It will be great if you consider a more in depth video about Redis. For example how to update the cashed data if it is updated in the DB? How to delete cashed data if it is deleted in the DB, best practices, etc. Great video!
@mohaniya15
@mohaniya15 Жыл бұрын
Thanks for this video Josh! Loved how easily you explained the entire concept!
@joshtriedcoding
@joshtriedcoding Жыл бұрын
Cheers man!
@codewithguillaume
@codewithguillaume Жыл бұрын
This usage Redis + Prisma is so smooth ❤
@joshtriedcoding
@joshtriedcoding Жыл бұрын
Really is. Works super well
@adnanniaz77
@adnanniaz77 Жыл бұрын
Thanks for this short, to the point and keeping is simple video. Keep it up 👍
@youneshenni5417
@youneshenni5417 Жыл бұрын
Thanks for the tips. Quick advice: always show how to invalidate cache for these kind of tutorials (as this is an important step in any caching process).
@CanRau
@CanRau 11 ай бұрын
Came here to say the same, important and can become complex in a real world production app 😅
@versaleyoutubevanced8647
@versaleyoutubevanced8647 6 ай бұрын
just delete the record?
@learnwhispering
@learnwhispering Жыл бұрын
Your explanation of how it works was brilliant - thank you 💕💕 You are clearly a brilliant man. Your skills at teaching are fantastic
@mounis
@mounis Жыл бұрын
Great video, simple and precise!
@eshw23
@eshw23 9 ай бұрын
Life saver, added this to my project thanks
@JT-mr3db
@JT-mr3db Жыл бұрын
Redis is really known as a caching layer but it's also an extremely capable primary database. If you can fit your data into RAM and work with the data structures Redis gives you, you will be a happy camper.
@gamingwolf3385
@gamingwolf3385 7 ай бұрын
But i think read and write operations will be more costy ??
@Ellenox147
@Ellenox147 Жыл бұрын
Clean video, thank you !
@harrypotil860
@harrypotil860 Ай бұрын
AWWWSOME explanation
@raymondmichael4987
@raymondmichael4987 Жыл бұрын
I really need to try this 😊, tons of usage
@raicubogdan8078
@raicubogdan8078 Жыл бұрын
Thanks! This was really helpful
@ScriptCodec
@ScriptCodec Жыл бұрын
Hey Josh, Great tuts! However I kind of get more curious about more advanced usage of redis. Could you make a dedicated video on redis? That would help a lot. Thanks. Great weekend!
@joshtriedcoding
@joshtriedcoding Жыл бұрын
Great idea. Wishing you that too
@namesare4fools
@namesare4fools Жыл бұрын
​@@joshtriedcoding we need a more practical use-case than this :)
@joshtriedcoding
@joshtriedcoding Жыл бұрын
@@namesare4fools There is going to be a *very* in-depth video soon. Stay tuned
@kdiffin903
@kdiffin903 Жыл бұрын
@@joshtriedcoding is it going to be using tRPC?
@dineshrout2527
@dineshrout2527 10 ай бұрын
Great explaination.
@zoki5388
@zoki5388 Жыл бұрын
Hey Josh 🍺, would Redis be a good place for storing the output (a very long string) of a rich text editor like React-Draft-Wysiwyg? Also, how could I store a link to it in my PostgreSQL database?
@DinoRossYT
@DinoRossYT Жыл бұрын
Nice one on Redis! Whats if data should be checked to see if its updated at db for objects a bit more dynamic?
@AmanRaj-zo7bx
@AmanRaj-zo7bx 9 ай бұрын
Loved this video, I am having problem with nodemon(in TS project), used ts-node but still not restarted on changes. can you please suggest a way to auto detect the file changes and compile and restart the server just like nodemon in js ?
@user-rd4oo1jg5g
@user-rd4oo1jg5g 9 ай бұрын
Very good video, I congratulate you. I ask you a question, suppose I have an application with a mysql database, my app calls an api to query and show products to the user, if I implement you Redis to cache the busquedaby that the api first see if you have stored in cache and if not just then go to query the database, with the first user who enters the app Eedis stored in the server cache and then if another user comes and asks to see the products would be set in that cache even if they are different users? The cache has a time and then it is deleted and the search to the database is done again, right? Thank you very much
@karthiksharmaslife2323
@karthiksharmaslife2323 6 ай бұрын
Hi Josh, can we do data manipulations directly in reddis cache and push the changes to the Database table without loading data from reddis cache to data table and manipulating the data? In my case data table cannot hold tons of data.
@GamingClubGermany
@GamingClubGermany 10 ай бұрын
Its cool but it could be a lot slower than just using the database directly if you using redis on cloud. If you backend need to connect via tcp to a different server anywhere you have a fast lookup but a slower response than using the local database directly. It would only make sense if you have very large requeste. But in general in memory caching is a really good idea but you loose manually editing the database manually (which is not recommended anyway) But good video as always!
@RETO_fps
@RETO_fps Жыл бұрын
but how does that work in terms of latency? one of the advantages of redis is 0ms(almost) access, but when used with upstash there surely is some ping latency. Can you tell if im right? Also what are other ways to implement redis with next, because cant find any :/ ps. gained sub
@AzzMdA
@AzzMdA 10 ай бұрын
can we use redis to cache postgresSQL (as a reading replica)?
@phantazzor
@phantazzor Жыл бұрын
so you are using query on the front and redis in the back?
@Jack-hk6kl
@Jack-hk6kl Жыл бұрын
Correct me if I’m wrong: doesnt Nextjs automatically implement this with their extended fetch API? If a fetch has the same parameters as before it would return the cached value. What’s the difference btwn that and Redis caching?
@joshtriedcoding
@joshtriedcoding Жыл бұрын
Pretty sure the nextjs values are only cached for YOU due to the serverless architecture, meaning if you and I request the same resource, my result wont be cached for you or the other way around. With redis, if we both request the same resource, it wil be cached for the later request
@0xPanda1
@0xPanda1 Жыл бұрын
NICE video
@joshtriedcoding
@joshtriedcoding Жыл бұрын
thanks champ
@bennys96
@bennys96 10 ай бұрын
How does this compare to the Next.JS default caching?
@ruanxun9454
@ruanxun9454 2 ай бұрын
Has anyone used vercel KV and can't seem to set the key value pair?
@journeyfromnothingtoeverything
@journeyfromnothingtoeverything 9 ай бұрын
Can we use Redis for my next js 13 backend?
@Tyheir
@Tyheir 9 ай бұрын
How useful is this with nextjs automatic caching?
@roncanfil
@roncanfil Жыл бұрын
how do you return NEW data from the database if it's always checking redis first?
@joshtriedcoding
@joshtriedcoding Жыл бұрын
You can fine-tune expiry times with redis
@LaklukLP
@LaklukLP Жыл бұрын
Love your videos man. I was wondering if you are looking for a position currently? I saw that you live n Germany based on your server geo selection ;) I have a startup and we are currently hiring again.
@efehanturhan6763
@efehanturhan6763 Жыл бұрын
hey josh, i wonder your toughts on t3 stack and trpc for production level development.
@joshtriedcoding
@joshtriedcoding Жыл бұрын
I've moved away from tRPC at the moment with NextJS 13 development, but have used it in production nevertheless and it held up well
@shakalbadlalega
@shakalbadlalega Жыл бұрын
How to make video for KZfaq? Which software you use?
@hn3m3s1s
@hn3m3s1s Жыл бұрын
Hey! Thanks for the video. You said that the Redis should be as close as possible of the users. But Actually wouldn't make more sense to have the Redis as close as possible of the Server than the users?
@joshtriedcoding
@joshtriedcoding Жыл бұрын
Your servers should also be as close to the users as possible, the closer the entire infrastructure the better
@hn3m3s1s
@hn3m3s1s Жыл бұрын
@@joshtriedcoding sure :) thanks
@hakancavdar3661
@hakancavdar3661 11 ай бұрын
Is it safe to use UpStash in production ? I have a to create an real estate website, i get all the data from an external api call, so it will be very use full to cache it. Any suggestion ? Thanks
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
yeah for sure, give it a shot
@adarshrajjaiswal9143
@adarshrajjaiswal9143 5 ай бұрын
you look like cart titan :)
@Gutan92
@Gutan92 Жыл бұрын
Are you using a drawing pen? Can't make mine work with Excalidraw, XP-PEN
@maazkhan9512
@maazkhan9512 Жыл бұрын
Nice Intro
@jason_v12345
@jason_v12345 Жыл бұрын
I'd be interested to see what it can do that can't be done just as easily with a global object.
@joshtriedcoding
@joshtriedcoding Жыл бұрын
Cache queries across different clients
@jason_v12345
@jason_v12345 Жыл бұрын
@@joshtriedcoding But can't I do that with just a simple global object of key-value pairs? global.cache = { [url]: [json] }
@bnv1n
@bnv1n 10 ай бұрын
@@jason_v12345persistence for example
@SupertigerDev
@SupertigerDev Жыл бұрын
You forgot to JSON.parse the cache response 😅😅
@ammaraateeb1914
@ammaraateeb1914 11 ай бұрын
Farq me its awesome
@MerthanMerter
@MerthanMerter 5 ай бұрын
thats like %0.2 of "Redis Caching for Incredible Performance"
@kag3670
@kag3670 Жыл бұрын
Very German intro👍
@joshtriedcoding
@joshtriedcoding Жыл бұрын
very "german"?? How haha
@crazytydoo
@crazytydoo Жыл бұрын
Josh, how can we give you money
@peaqe2496
@peaqe2496 18 күн бұрын
Bro dieses denglisch hahaha
@greendsnow
@greendsnow 8 ай бұрын
redis and upstash are not the same thing. upstash costs a lot of money.
@basarat
@basarat Ай бұрын
What’s cheaper?
@asimalqasmi7316
@asimalqasmi7316 Жыл бұрын
first here ^_*
@loveboat
@loveboat 11 ай бұрын
What? A database that stores cached values instead of... checking an actual database? What have we saved here? This is moronic.
@rumble1925
@rumble1925 11 ай бұрын
Performance
@fahadshinwari6844
@fahadshinwari6844 9 ай бұрын
Redis has no idea whether the data in DB has been updated. Normally, we use Redis to cache data as follows: 1- Client checks if the data, e.g. key-value pair, exists in Redis. 2- If the key exists, client gets the corresponding value from Redis. 3- Otherwise, it gets data from DB, and sets it to Redis. Also client sets an expiration, say 5 minutes, for the key-value pair in Redis. 4- Then any subsequent requests for the same key will be served by Redis. Although the data in Redis might be out-of-date. 5- However, after 5 minutes, this key will be removed from Redis automatically. 6- Go to step 1. So in order to keep your data in Redis update-to-date, you can set a short expiration time. However, your DB has to serve lots of requests. If you want to largely decrease requests to DB, you can set a large expiration time. So that, most of time, Redis can serve the requests with possible staled data. You should consider carefully about the trade-off between performance and staled data.
Redis Crash Course
27:31
Web Dev Simplified
Рет қаралды 603 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 334 М.
Haha😂 Power💪 #trending #funny #viral #shorts
00:18
Reaction Station TV
Рет қаралды 16 МЛН
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 4,8 МЛН
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 33 МЛН
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 4 МЛН
Fetching Data Doesn't Get Better Than This
6:58
Josh tried coding
Рет қаралды 88 М.
How does Caching on the Backend work? (System Design Fundamentals)
22:45
Software Developer Diaries
Рет қаралды 31 М.
Devlog #11- How to make your DB fast by using Caching
8:34
Superthread
Рет қаралды 12 М.
A Better Way to Write APIs?
12:00
Josh tried coding
Рет қаралды 88 М.
This Package Saved My SaaS
5:46
Josh tried coding
Рет қаралды 109 М.
Python and Redis Tutorial - Caching API Responses
32:26
Part Time Larry
Рет қаралды 54 М.
tRPC, gRPC, GraphQL or REST: when to use what?
10:46
Software Developer Diaries
Рет қаралды 72 М.
NestJs caching with Redis
18:17
Computerix
Рет қаралды 3,9 М.
Caching API Responses with Redis
22:57
Redis
Рет қаралды 21 М.
OZON РАЗБИЛИ 3 КОМПЬЮТЕРА
0:57
Кинг Комп Shorts
Рет қаралды 506 М.
Игровой Комп с Авито за 4500р
1:00
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,9 МЛН
Урна с айфонами!
0:30
По ту сторону Гугла
Рет қаралды 8 МЛН