Django Cache Versioning
But there are some problems with this approach. For one, the first (uncached) request still takes the full 3.5 seconds.
.. Django supports “versioning” of cache records. If you specify a version number in your
cache.set(key, value, version=my_version)
call, then a correspondingcache.get(key, version=some_other_version)
call will not return any data. Using versioning, we can change things around and store the user’s current ‘version’ in the cache. When we want to get the cached data set, we specify the user’s cached version number. In this way, we are able to invalidate old cache entries without searching through the cache for all of a user’s cached items. An example will help clarify: