Redis

How do I implement Redis in my app on railway and use it?
33 Replies
Percy
Percy15mo ago
Project ID: cbf50408-4c4f-4a5e-adcf-0f5cdbd02b69
KennyTech
KennyTech15mo ago
cbf50408-4c4f-4a5e-adcf-0f5cdbd02b69
Brody
Brody15mo 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
KennyTech15mo 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
Brody15mo ago
add a redis plugin, then setup the variable references in your service, then use the environment variables in your code to connect
KennyTech
KennyTech15mo 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
Brody15mo 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
KennyTech15mo 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
Brody15mo 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
KennyTech15mo ago
Mr Brody I'm not asking how to program. I'm asking how to use your services
Brody
Brody15mo ago
^
KennyTech
KennyTech15mo ago
That's why I'm asking for references
Brody
Brody15mo ago
have you added a redis database plugin to your project yet?
KennyTech
KennyTech15mo 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
Brody15mo ago
?
KennyTech
KennyTech15mo ago
...
Brody
Brody15mo ago
I think it's like 3 button pushes to add the database plugin to your project...
KennyTech
KennyTech15mo 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
Brody15mo ago
sure
KennyTech
KennyTech15mo 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
Brody15mo 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
KennyTech15mo 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
Brody15mo 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
KennyTech15mo 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
Brody15mo 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
KennyTech15mo 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
Brody15mo ago
sounds like you need another service to hand tasks off to
KennyTech
KennyTech15mo 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
Brody15mo ago
yep you need some kind of external worker or task queue there's plenty of tutorials floating around the internet for that
KennyTech
KennyTech15mo ago
But this is not redis? Thanks
Brody
Brody15mo ago
yeah there's workers that save state into a redis database
KennyTech
KennyTech15mo ago
Okay, I'll take it from here Thanks for your help
Brody
Brody15mo ago
sounds good no problem