Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django load objects instances just once, make them available starting app [closed]

Tags:

python

django

I have an app (Django 1.6) that uses around 4000 objects, for natural language processing (NLP), previously generated.

All application processes (requests, tests, custom management commands, etc) need to use all of those objects in some way.

What I'd like to do is to load all of those objects, just once, at the startup moment (or so), and store them in memory to make them available for all app processes.

This post has some clues but I'd love to hear your thoughts about what is the best approach to the situation.

Clarification: The 4000 objects are used just for reading in all processes, they are not being modified in any way into the app.

Thank you so much.

like image 853
tufla Avatar asked Nov 10 '22 09:11

tufla


1 Answers

You may want to put all the data into the cache and also take advantage of Memcached cache backend. So the data could be fast, safely and easily accessed by any of your processes.

like image 127
isobolev Avatar answered Nov 15 '22 06:11

isobolev