Redis

How do I implement Redis in my app on railway and use it?
33 Replies
Percy
Percy2y ago
Project ID: cbf50408-4c4f-4a5e-adcf-0f5cdbd02b69
KennyTech
KennyTechOP2y ago
cbf50408-4c4f-4a5e-adcf-0f5cdbd02b69
Brody
Brody2y ago
read some tutorials watch some YouTube videos, etc. I apologize but these threads are not for us to teach you how to program
KennyTech
KennyTechOP2y ago
I have seen no videos on this, I went to the docs and saw how to add redis variables. I didn't see their value in the railway docs that is why I'm here If you have reference(s) just paste it and I will follow
Brody
Brody2y ago
add a redis plugin, then setup the variable references in your service, then use the environment variables in your code to connect
KennyTech
KennyTechOP2y ago
Wow thanks, but please one more, the redis plugins is on the railway platform where my app is hosted, or I should add it as an npm package in my app?
Brody
Brody2y ago
you would need to add the redis database plugin to your project on railway, to connect to the redis database you would need to use a package to connect to redis
KennyTech
KennyTechOP2y ago
Wow, this is now sounding kind of difficult, is there any reference online you could point to me so that I can follow. Cause in the docs I didn't see the plugins and database setups as steps before implementing redis
Brody
Brody2y ago
it's not difficult, you might just be overthinking it as for how to use redis, that's something you will have to learn yourself, as I said above these threads are not for us to teach you how to program
KennyTech
KennyTechOP2y ago
Mr Brody I'm not asking how to program. I'm asking how to use your services
Brody
Brody2y ago
^
KennyTech
KennyTechOP2y ago
That's why I'm asking for references
Brody
Brody2y ago
have you added a redis database plugin to your project yet?
KennyTech
KennyTechOP2y ago
Ok. Thanks I was working on it before I became too frustrated and shutdown my system I will follow your instructions If any issues I will come back Thanks 🙏
Brody
Brody2y ago
?
KennyTech
KennyTechOP2y ago
...
Brody
Brody2y ago
I think it's like 3 button pushes to add the database plugin to your project...
KennyTech
KennyTechOP2y ago
Ok, when I put on my system I will follow up your instructions Thanks again Mr Brody one last question Can I ask?
Brody
Brody2y ago
sure
KennyTech
KennyTechOP2y ago
Ok I understand what you started earlier as this thread is not for programming tutorial. I have a timing function that performs an action every minute. After I make changes in my app and redeploy it to railway, my timer stops. I want it to continue after the redeployment. Is redis the solution? If not suggest for me let me read the solution. I know I can solve it
Brody
Brody2y ago
once you redoploy your old code gets removed and replaced with the new code, why wouldn't the new code just start another timer when it starts up?
KennyTech
KennyTechOP2y ago
When a user is approved in my app by admin, a record will be created in the database for every minute for seven minutes. When I make a change my code will check my tracking time and know the time remaining then complete the action. But when I make a change and redeploy it in railway the record created will be more than seven. Then I started looking online for solutions before coming across redis
Brody
Brody2y ago
nah you just want to store the date stamp on initial creation and check it against the current date whenever you access the data, you shouldn't need timers or anything like that
KennyTech
KennyTechOP2y ago
Here you go again, you just humbled me that I have more to know. I thought about it cause the issue might be coming from the time zones
Brody
Brody2y ago
speaking of time zones, you should be doing all the date stamps and time calculations in UTC, and only convert out to the users local time zone for display purposes
KennyTech
KennyTechOP2y ago
But why I need timer is because at the end of the seven minutes from the time of approval, the user gets an email So I started looking for what will keep my process running even after my app is restarted on railway
Brody
Brody2y ago
sounds like you need another service to hand tasks off to
KennyTech
KennyTechOP2y ago
If I didn't make changes and the app didn't restart. At exactly seven minutes the whole process will work But if I make changes and redeploy my work, the problem I explained will occur
Brody
Brody2y ago
yep you need some kind of external worker or task queue there's plenty of tutorials floating around the internet for that
KennyTech
KennyTechOP2y ago
But this is not redis? Thanks
Brody
Brody2y ago
yeah there's workers that save state into a redis database
KennyTech
KennyTechOP2y ago
Okay, I'll take it from here Thanks for your help
Brody
Brody2y ago
sounds good no problem
Want results from more Discord servers?
Add your server