Absence of data not cached
Perhaps this is by design or a known limitation, but I thought I'd file it anyway. Working on performance tuning Django CMS, I realized the following query is never cached when exists() is False:
This is because this query returns None inside of has_results (django/db/models/sql/query.py line 424 in version 1.3.1.) It looks like johnny-cache doesn't distinguish between a cache hit of None and a cache miss:
val = self.cache_backend.get(key, None, db) }}}
Since Django seems to suggest not caching a literal None I'm not sure this is possible to fix. You could choose a different representation for None but it would need to be something that wouldn't collide with a valid string response. Maybe the key?