[Fixed]-How to cache a Django Model in Memory

14👍

You can use Django’s provided caching.

This answer to a very similar question gets you on the right track.

👤Joseph

1👍

I would suggest implementing a custom model manager and a query set. A django cache backend doesn’t have to be memcached or redis it can be localmemory also, although I would advise you to stand up a real cache backend. We mostly have been using https://github.com/jmoiron/johnny-cache for this purpose but found it is not compatible with django > 1.6 so we are switching over to https://github.com/vijaykatam/django-cache-manager

Leave a comment