Object storage for objects in Django between requests

I had the following idea: let's say we have a webapp written using django that models some kind of bulletin board. This board has many threads, but some of them get most posts / views per hour. Stream pages look a little different for each user, so you cannot cache the entire displayed page, and only some parts of the displayed page are also not cached.

My idea: I create an object structure of the stream in memory (with each mail and other data necessary to display it). If a new message is published, the structure is updated, and each post X (or every Y minutes, no matter what comes first), new messages are written back to the database. If the application crashes, some messages are lost, but it is definitely good (for users and administrators).

Question: can I create such a constant in memory without serialization (so no serialize-> memcached)? As far as I understand, WSGI applications (like Django) work in a continuous process without stopping between requests, so this should be possible in theory. Is there any API I could use? If not: any item to view?

/ edit1: I know that "persistent" usually has a different meaning, but in this case, I strictly mean "between requests."

+5
source share
2 answers

In a WSGI production environment, you are likely to have several workflows serving requests at the same time. These workflows will be processed from time to time, that is, local memory objects will be lost.

But if you really need it (and make sure you do it), I suggest you study the Django caching structure, check local memory caching. Also, see sessions .

( pickle). (. ). locmem.py .

, ?

+6

, .

, , - X . , . , . , , .

, . , , . , , , , .

: . , . .

0

All Articles