What you offer is directly impossible. Since new processes can be deployed up and down beyond your control, there is no way to store Python embedded data in memory.
However, there are several ways around this.
Often, one level of key value storage is all you need. And sometimes, having fixed buffers for values (which you can use directly as str / bytes / bytearray , all you need for a struct to be serialized there or otherwise) is all you need. In this case, the uWSGI built-in caching infrastructure will take care of everything you need.
If you need more precise control, you can see how the cache is implemented on top of SharedArea and do something customizable. However, I would not recommend this. This basically gives you the same API that you get with the file, and the only real advantages over using the file is that the server will control the lifetime of the file; it works in all languages supported by uWSGI, even those that do not allow files; and makes it easy to port your user cache to a distributed (multi-computer) cache if you need it later. I do not think any of them applies to you.
Another way to get flat storage with a key, but without fixed-size buffers is with Python stdlib anydbm . The search by key value is the same as pythonic: it looks the same as dict , except that it backs up the BDB database (or similar) to a disk cached as it is required in memory, instead of being stored in a hash table in memory.
If you need to handle a few other simple types - all that are incredibly fast for un / pickle, like int s - you can consider shelve .
If your structure is tight enough, you can use the key database for the top level, but access the values through ctypes.Structure or de-serialize with struct . But usually, if you can do this, you can also eliminate the upper level, and at this point all this is just one big Structure or Array .
At this point, you can simply use a simple file for storage - either mmap it (for ctypes ), or just open and read it (for struct ).
Or use multiprocessing Common ctypes Objects to access your Structure directly from the shared memory area.
Meanwhile, if you don’t really need all the cache data all the time, just bits and pieces every once in a while, for which databases are needed. Again, anydbm etc. It may be all you need, but if you have a complex structure, create an ER diagram, turn it into a set of tables and use something like MySQL.