Commits

bes committed 7d5a974
  • Participants
  • Parent commits be0ef70

Comments (0)

Files changed (1)

File johnny/cache.py

                 signals.qc_hit.send(sender=cls, tables=tables,
                         query=(sql, params, cls.query.ordering_aliases),
                         size=len(val), key=key)
-                if val is sentinel:
+                if val == sentinel:
                     return None
                 return val
 
                 #todo - create a smart iterable wrapper
                 val = list(val)
             if key is not None:
-                self.cache_backend.set(key, val or sentinel, settings.MIDDLEWARE_SECONDS, db)
+                cached_val = val
+                # We cannot just do: cached_val = val or sentinel
+                # Because val can be something like [] (an empty queryset)
+                if cached_val is None:
+                    cached_val = sentinel
+                self.cache_backend.set(key, cached_val, settings.MIDDLEWARE_SECONDS, db)
             return val
         return newfun