There is some data from database which is rarely changing and needs to be stored in redis. I know how to setup the redis-py and django-redis. I know how to set key and values and get them. But the question is the setting of data is to be universal and out of any specific function. Where should i put the code to set key and values for such data.
Asked
Active
Viewed 319 times
-1
-
Are you talking about initial loading of the data? Or setting data to redis in the application? – Malinga Jun 29 '16 at 10:51
-
Initial loading of data. – Vedant Jain Jun 29 '16 at 11:00
1 Answers
0
No matter its redis or any other database. Its good to have a data layer, a API to call those functions. As you might want to call redis with in the application its good to have a API. To give you a idea, have methods for redis GET, SET, etc.. (this will change based on the data structure u use).
For initial loading have a separate script. Don't add it to the application code. Because it will be used only once and there is no point of adding that code to the application code base. In these scripts you can use the same API you wrote for the application. And this scripts don't have to be great code. This will get the job done and you can keep it aside after initial loading.

Malinga
- 505
- 3
- 14