Implementation of lru_cache for daily "top categories" query
From what I understand, the lru_cache is not the right tool when it comes to caching things in a production web application. Depending on how the web application is deployed, you would usually end up having multiple web server processes serving your application. Which means, that the LRU cache will be created in the memory space of every process. It's like if you would use the local-memory caching:


  Note that each process will have its own private cache instance, which
  means no cross-process caching is possible. This obviously also means
  the local memory cache isn’t particularly memory-efficient, so it’s
  probably not a good choice for production environments. It’s nice for
  development.


In other words, you should not be caching with Python, cache with Django built-in caching mechanisms in an external storage - a database, or a memcached or redis instance.    For instance, in a simple case to avoid external dependencies, you can just use a cache table in your database:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
        'LOCATION': 'my_cache_table',
    }
}


Then, you can cache the result of top_categories in this table, letting Django handle the cache record expiration.