Using Django Settings to cache a timestamp
So the short answer to this question: Do not store global runtime data in Django's settings. Each new process thread will create its own instance of settings, meaning that your application will behave differently in each thread, or you'll have to run your app in single threaded mode (bad for performance).
If you need to store this kind of data either use the Django Caching Framework, a database or the filesystem.
I want to use the Django Settings to indefinitely store a value. This value will change throughout the life span of the server process and should not be forgotten. See, what I am trying to do is generate a static file on my server's file system and store its generation time in django.conf.settings.
I am more than aware that all settings are lost when the fcgi server is restarted, this is ok. But, the behavior (and problem) I'm seeing is that the setting is being reset every so often. I cannot determine why it is being reset, it seems fairly random.
Does anyone out there know if Django resets its settings every so often? or should I be looking for a bug in my logic? How about another way to achieve what I want? Could this be related to running the fcgi server in threaded mode?
I may just end up writing the timestamp to the filesystem, we will see...
PS: My code works as expected when I use Django's local lighttp server.
PPS: Django's Caching Framework would probably have been a smart way to get what I want, but at this point I won't be able to use it :(