Learn how to do caching in NodeJS using Redis

  Рет қаралды 33,256

Mafia Codes

Mafia Codes

Күн бұрын

In this video, using the #SpaceX #api - we will learn how to do #caching in a #nodejs #express application.
We will be using #redis in-memory #database to #cache out data.
0:00 Introduction
0:48 Redis
1:03 Redis installion on MacOS
2:30 SpaceX API preview
2:58 Project
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I've been using Kite for 6 months and I love it! www.kite.com/get-kite/?...
FREE $100 credit @Digital Ocean: m.do.co/c/3208f08b3324
Subscribe: kzfaq.info...
Support the channel:
Paypal: www.paypal.me/trulymittal
Patreon: / trulymittal
Github (full-tutorial): github.com/trulymittal/cachin...
SpaceX API: docs.spacexdata.com/
---------------
Other useful Playlists
---------------
#RestAPI (#NodeJS and MongoDB): • REST API using NodeJS ...
#API Authentication using #JWT: • NodeJS API Authenticat...
#Firebase: • Firebase | Build a Not...
Docker: • Docker
MongoDB: • Learn MongoDB in 50 mi...
Html/Css/Js: • HTML / CSS / JS
Android: • Android
Challenges: • Challenges
---------------
What I use
---------------
Mouse: amzn.to/2O9RJtu
Keyboard: amzn.to/2qxajCU
Keyboard 2: amzn.to/2XDWH4X
Monitor: amzn.to/2pDg7dH
Processor: amzn.to/347WWIb
RAM: amzn.to/2QEkUqw
Graphics: amzn.to/33aBrF4
Microphone: amzn.to/2DabdI9
#StayHome #WithMe #yoursTRULY #tutorial #howto #android

Пікірлер: 97
@kiranojha8811
@kiranojha8811 2 жыл бұрын
The latest version of redis is asynchronous so no need to make custom functions. You can simply use the client. For instance, const reply = await client.GET(`rockets`) await client.setEx("recipes", 5, JSON.stringify(response.data)) const reply = await client.GET(`rocket-${id}`) await client.setEx(`rocket-${id}`, 5, JSON.stringify(response.data))
@pablocazin1698
@pablocazin1698 2 жыл бұрын
thx a lot
@darshankarkera3153
@darshankarkera3153 2 жыл бұрын
thanks
@kiranojha8811
@kiranojha8811 2 жыл бұрын
no problem
@nriketube
@nriketube 3 жыл бұрын
I used Redis with Php, I found an excelent video and explanation for Node Js. Congrats! Thank U!!
@amankhanna354
@amankhanna354 2 жыл бұрын
Just discovered your channel and I’m binge watching all your nodejs videos. Thank you for this🙌🏻🔥
@sulemanahsan7913
@sulemanahsan7913 Жыл бұрын
Same here 💫
@firojsiddiki2750
@firojsiddiki2750 3 жыл бұрын
your videos are direct to the point everytime. I like this
@cse_29_abdulshariqkalim15
@cse_29_abdulshariqkalim15 2 жыл бұрын
The Best Video I Got It After Searching 3 consecutive days
@tastaslim
@tastaslim 3 жыл бұрын
Best tutorial for redis. Thanks man. I like the way you write code(like me😀). Clean and easy to understand.
@suyashpurwar8310
@suyashpurwar8310 3 жыл бұрын
Thanks for this! Your explanation was very clear and it was very easy to grasp everything. Looking forward to learning more about Redis caching.
@mafiacodes
@mafiacodes 3 жыл бұрын
Glad it was helpful!
@aiwanmaswood9219
@aiwanmaswood9219 3 жыл бұрын
thank you so much, earlier I thought implementation of radis will be tough. Thankx alot
@dontargetme2416
@dontargetme2416 3 жыл бұрын
i'm sharing your videos and it's the least i can do , thanks for sharing your knowledge
@Antnix732
@Antnix732 3 жыл бұрын
Wow this is some of the cleanest code I've seen in a while. Thank you.
@mafiacodes
@mafiacodes 3 жыл бұрын
You're welcome!
@akashnag3879
@akashnag3879 3 жыл бұрын
very well explained. i never found out how to use redis. the answer is here. please do come up with more such videos.
@mafiacodes
@mafiacodes 3 жыл бұрын
Subscribe like
@avidambassador6665
@avidambassador6665 2 жыл бұрын
Elegant piece of code. Thank you.
@asenalig5384
@asenalig5384 Жыл бұрын
Thank you for this video bro... Really this is helpful for my new project... Clear explanation.... Thank you so much man... keep rocking...
@bhaskarsahni1016
@bhaskarsahni1016 3 жыл бұрын
Thanks a lot. clear cut and clean too
@mysterOrel7924
@mysterOrel7924 3 жыл бұрын
Thx Man ! I'm using Redis for my own project and it's working so far. But I didn't know about the built in promisify function in node lol. I can say it helps a lot because it's was a hard work to deal with the callback on each Redis GET function ( GET, HGET, HGETALL ... ). I was watching this kinda video just to find things like this, little but very helpful. This video is one top of that very clear for beginners.
@mafiacodes
@mafiacodes 3 жыл бұрын
Great to hear! Subscribe like share...
@mysterOrel7924
@mysterOrel7924 3 жыл бұрын
@@mafiacodes for sure
@ShwetaSingh-nw3nq
@ShwetaSingh-nw3nq 3 жыл бұрын
This is exactly what I was looking for , I am a beginner...Thank you for this video...
@mafiacodes
@mafiacodes 3 жыл бұрын
Glad that you like 😊
@verdipratama
@verdipratama 3 жыл бұрын
easy to understand, thank you :))
@rfhacknikola
@rfhacknikola 3 жыл бұрын
thank you soo much brother!!!
@siddheshmhatre2389
@siddheshmhatre2389 3 жыл бұрын
Previously i thought it was difficult to use redis but after this video i am able to do it in 30min💥nice video much love bro❤💥
@saurabhgupta6691
@saurabhgupta6691 3 жыл бұрын
Great video bro, You are awesome !!
@zamora322
@zamora322 3 жыл бұрын
Thanks for sharing bro. Regards from Mexico 🇲🇽.
@mafiacodes
@mafiacodes 3 жыл бұрын
My pleasure!
@bushranikhat2326
@bushranikhat2326 3 жыл бұрын
Thanks for the tutorial its really very helpful. 😊
@emeetv
@emeetv 3 жыл бұрын
Superb video
@kishanmaurya4865
@kishanmaurya4865 3 жыл бұрын
Great man ,
@manikirannirmala9954
@manikirannirmala9954 2 жыл бұрын
You are tooo good man.... Love you brother :)
@mafiacodes
@mafiacodes 2 жыл бұрын
Thank you so much 😀 Subscribe like share
@avicohen5110
@avicohen5110 3 жыл бұрын
amazing!
@stylesg7818
@stylesg7818 2 жыл бұрын
Thank you.
@shamilmammadov8246
@shamilmammadov8246 3 жыл бұрын
You have got a new follower)
@diego.coder26
@diego.coder26 3 жыл бұрын
Thanks
@manikandanraman
@manikandanraman 3 жыл бұрын
Asusual another useful tutorial at the right time. Thanks bro
@dontargetme2416
@dontargetme2416 3 жыл бұрын
will be great if you can make a video on testing for our API & add it to this series cant wait & thanks stay motivated you're awesome !
@mafiacodes
@mafiacodes 3 жыл бұрын
Which API?
@dontargetme2416
@dontargetme2416 3 жыл бұрын
@@mafiacodes node API's using JEST , i know that testing can't be covered in one video & it should be an entire series but you can make a usefull one & if there is a feedback from your community, you can do more (unit, integration, e&e)
@be_b_50_ankitkumar_singh79
@be_b_50_ankitkumar_singh79 3 жыл бұрын
Sir , please make a video on what to do if we have backend as MongoDB, that is how to integrate Redis with MongoDB. Thanks, you are the best.
@osherezra8460
@osherezra8460 3 жыл бұрын
Priceless tutorial thank you keep it up. great vibe and flow man thank you. just couple Qs please 1. How long can is it ok to keep cache if data is not changing often? 2. What do I need to to do in order to deploy apps with Redis? cheers bro
@captainalpha4853
@captainalpha4853 2 жыл бұрын
Same questions
@abhijeetshikharvlog1444
@abhijeetshikharvlog1444 2 жыл бұрын
I need one help in redis i write one client.get middle to get all values but how to make dynamic so that in all routes its work
@imkumawat
@imkumawat Жыл бұрын
Which color theme and font are using for the editor and terminal?
@sudeepkotari
@sudeepkotari 3 жыл бұрын
Sir which host we should mention when deploying server
@JohnSmith-gu9gl
@JohnSmith-gu9gl 2 жыл бұрын
can someone please explain why some people use hmset() to store a java object?
@PankajPatidar1
@PankajPatidar1 3 жыл бұрын
Bro please make video on proguard..
@noorulamin2652
@noorulamin2652 3 жыл бұрын
Awesome tutorial ! can you tell me how to can i set font style which you have set on your vscode?
@mafiacodes
@mafiacodes 3 жыл бұрын
Operator mono font
@imkumawat
@imkumawat Жыл бұрын
bhai konsi theme and font use kar rhe ho
@Ruhgtfo
@Ruhgtfo 3 жыл бұрын
noice
@technoinfoworldwide2329
@technoinfoworldwide2329 3 жыл бұрын
make a video on hiding api key with rate limiting using node js
@daveraj1958
@daveraj1958 3 жыл бұрын
@yours truly what type of extension you are using in vs code , please make a video on that too. Awesome work👍
@mafiacodes
@mafiacodes 3 жыл бұрын
Which type of extension, rest client?
@daveraj1958
@daveraj1958 3 жыл бұрын
@@mafiacodes no , the one that prints inline output in vs code as a comment , and rest of all extensions also...👍
@mafiacodes
@mafiacodes 3 жыл бұрын
I cannot get which inline output
@daveraj1958
@daveraj1958 3 жыл бұрын
@@mafiacodes beside of required statement like 5.kb used etc..🙏
@mafiacodes
@mafiacodes 3 жыл бұрын
Import cost
@chrootandrex1779
@chrootandrex1779 2 жыл бұрын
Hi, Can i use this if I am changing my api's data every other day?
@mafiacodes
@mafiacodes 2 жыл бұрын
Yes, provide a refresh interval related to ur use case
@emeetv
@emeetv 3 жыл бұрын
One more question..how much memory it requires to handle proper redis and in what type of application redis can be used...small applications? Thank you so much for your previous answer
@mafiacodes
@mafiacodes 3 жыл бұрын
For production atleast 2gb ram
@emeetv
@emeetv 3 жыл бұрын
@@mafiacodes thank you so much
@emeetv
@emeetv 3 жыл бұрын
I have one question ..what if we have database and web server both on same machine.will it be useful to use redis cache or we can make direct call because server and database are on same machine?
@mafiacodes
@mafiacodes 3 жыл бұрын
Still useful, since redis is in-memory so reading from memory is way faster than reading from disk.
@pancard4361
@pancard4361 2 жыл бұрын
sir, which font do you use on editor? pl suggest ...
@mafiacodes
@mafiacodes 2 жыл бұрын
Operator mono
@musiclyrics4166
@musiclyrics4166 3 жыл бұрын
Can you please share Theme you are using along with Fonts Family name?
@mafiacodes
@mafiacodes 3 жыл бұрын
Snazzy operator theme, operator mono font
@msuleman7786
@msuleman7786 2 жыл бұрын
I'm getting this error (node:11248) UnhandledPromiseRejectionWarning: Error: The client is closed Can anyone help me?
@anjannair2432
@anjannair2432 2 жыл бұрын
Just add a line of code `client.connect()` below the `const client = ....`
@ShwetaSingh-nw3nq
@ShwetaSingh-nw3nq 3 жыл бұрын
How can we display cached data from redis into html , res.render() ? Since we have the data stringified before to save it. Thanks.
@mafiacodes
@mafiacodes 3 жыл бұрын
If ur doing server side rendering, then u shud use a templating engine like “EJS”, you can watch this video to see how ejs works kzfaq.info/get/bejne/eL6lhZmmyNnHep8.html though it’s a video to create short links but ejs part remains the same.
@ShwetaSingh-nw3nq
@ShwetaSingh-nw3nq 3 жыл бұрын
@@mafiacodes Actually my questions was incorrect, it was about caching the html itself and rendering cached html rather than data(json). Wanted to implement this: res.render('showList',{shows:data},async(err,html)=>{ await client.setAsync('movieList',html); res.send(html); Thank you. I watched the ejs video too.
@mafiacodes
@mafiacodes 3 жыл бұрын
So ur doubts cleared?
@ShwetaSingh-nw3nq
@ShwetaSingh-nw3nq 3 жыл бұрын
@@mafiacodes yes, thanks
@mafiacodes
@mafiacodes 3 жыл бұрын
Gr8, feel free for any queries n doubts...
@akashsaha9366
@akashsaha9366 3 жыл бұрын
How implement radis db server over the web. Like in other server. We are going to call it node.js?
@mafiacodes
@mafiacodes 3 жыл бұрын
Redis db can be installed on any Linux os
@akashsaha9366
@akashsaha9366 3 жыл бұрын
@@mafiacodes I am asking about hosting provider online. Where I will host my server. How to do that? And this can be installed ina ny windows system?
@mafiacodes
@mafiacodes 3 жыл бұрын
Windows not advisable for redis, you can host on aws or digital ocean on run a docker image on zeet
@diego.coder26
@diego.coder26 3 жыл бұрын
Example with django please
@mafiacodes
@mafiacodes 3 жыл бұрын
maybe sometime later
@AlexanderYaremchuk
@AlexanderYaremchuk Жыл бұрын
newer redis client 1) returns promises 2) requires explicit open call
@mafiacodes
@mafiacodes Жыл бұрын
Yes I know 🙂
@tambolaking5383
@tambolaking5383 3 жыл бұрын
That's so wrong intro. Use caching when data is fetched often. Not when data doesn't change often
@mafiacodes
@mafiacodes 3 жыл бұрын
A cache's primary purpose is to increase data retrieval performance by reducing the need to access the underlying slower storage layer. In a messaging app or notifications - data is fetched quickly, so should you cache - NO.
@aces-group
@aces-group 2 жыл бұрын
misleading kids ...this is simple backlink to api....stupid routing...not a single page in real time show..forget this restclı..is macbook cach localshit has no reflection to real server to customer location...blender ..in general what common it guys shows ytb views generating ...sorry nogo
@shuvamdutta6359
@shuvamdutta6359 Жыл бұрын
return Promise.reject(new errors_1.ClientClosedError()); ^ ClientClosedError: The client is closed at Commander._RedisClient_sendCommand (C:\MY WORKS\NODE\Node Small Projects\Node-caching ode_modules\@redis\client\dist\lib\client\index.js:490:31) at Commander.commandsExecutor (C:\MY WORKS\NODE\Node Small Projects\Node-caching ode_modules\@redis\client\dist\lib\client\index.js:188:154) at BaseClass. [as get] (C:\MY WORKS\NODE\Node Small Projects\Node-caching ode_modules\@redis\client\dist\lib\commander.js:8:29) at node:internal/util:364:7 at new Promise () at Commander. (node:internal/util:350:12) at C:\MY WORKS\NODE\Node Small Projects\Node-caching\index.js:19:25 at Layer.handle [as handle_request] (C:\MY WORKS\NODE\Node Small Projects\Node-caching ode_modules\express\lib outer\layer.js:95:5) at next (C:\MY WORKS\NODE\Node Small Projects\Node-caching ode_modules\express\lib outer oute.js:144:13) at Route.dispatch (C:\MY WORKS\NODE\Node Small Projects\Node-caching ode_modules\express\lib outer oute.js:114:3) Node.js v18.12.1 This error is occurring when running your code, please advice
@JonathanZufi
@JonathanZufi 3 жыл бұрын
Kudos. Great job and really well done - bare minimum dependencies to demonstrate the basics of get/set within a Node environment. Thank you!
@mafiacodes
@mafiacodes 3 жыл бұрын
Glad you enjoyed it!
How to make a URL shortener application in Nodejs using mongodb
34:29
Redis Crash Course
27:31
Web Dev Simplified
Рет қаралды 603 М.
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 33 МЛН
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 511 М.
Mastering Memory Management in Node.js: Tips and Tricks for Better Performance
16:06
Software Developer Diaries
Рет қаралды 28 М.
How to scale NodeJs applications using the cluster module.
13:37
Mafia Codes
Рет қаралды 49 М.
How to generate and use a SSL certificate in NodeJS
13:59
Mafia Codes
Рет қаралды 105 М.
Cache Systems Every Developer Should Know
5:48
ByteByteGo
Рет қаралды 455 М.
Caching API Responses with Redis
22:57
Redis
Рет қаралды 21 М.
How to use Multithreading with "worker threads" in Node.js?
19:34
Software Developer Diaries
Рет қаралды 50 М.
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 33 МЛН