pythondjangolocal-storagenon-volatile

What's the best non-volatile way of storing data for a Django 2.0 project?


I want to create an app using Django that users can interact with and post to using HTTP requests, but I don't want to store the data in a database, the data should be lost once the server is turned off. I was thinking of using arrays and sessions but I'm just wondering if there are other options. It is a very simple app only storing strings and integers. Thank you in advance!


Solution

  • This really depends on the complexity of your server architecture and what type of data you're trying to store.

    You can use Django's cache framework to abstract away the backend that you actually use to store the data. It's configurable to use either a Python dictionary, Memcached (which is entirely volatile), or redis (you'll have to install another module and configure redis not to persist to disk).

    The advantage of using Memcached or redis is that they're easily able to handle multiple processes and threads mutating the data and can survive your Python process restarting.