Commit 712b0d99 authored by Ales Zoulek's avatar Ales Zoulek

Removed django incompatibility

Django is using timeout=0 to use default timeout value.

Using timeout=0 to set non-volatile keys conflicts with django API.
parent ac1da82b
...@@ -130,13 +130,8 @@ class CacheClass(BaseCache): ...@@ -130,13 +130,8 @@ class CacheClass(BaseCache):
Set content expiration, if necessary Set content expiration, if necessary
""" """
key = self.make_key(key, version=version) key = self.make_key(key, version=version)
if timeout is None: if not timeout:
timeout = self.default_timeout timeout = self.default_timeout
if timeout <= 0:
# force the key to be non-volatile
result = self._cache.get(key)
self._cache.set(key, result)
else:
# If the expiration command returns false, we need to reset the key # If the expiration command returns false, we need to reset the key
# with the new expiration # with the new expiration
if not self._cache.expire(key, timeout): if not self._cache.expire(key, timeout):
......
...@@ -195,14 +195,6 @@ class RedisCacheTests(TestCase): ...@@ -195,14 +195,6 @@ class RedisCacheTests(TestCase):
self.cache.set(key, value); self.cache.set(key, value);
self.assertTrue(self.cache._cache.ttl(key) > 0) self.assertTrue(self.cache._cache.ttl(key) > 0)
def test_set_expiration_timeout_0(self):
key, value = self.cache.make_key('key'), 'value'
self.cache.set(key, value)
self.assertTrue(self.cache._cache.ttl(key) > 0)
self.cache.expire(key, 0)
self.assertEqual(self.cache.get(key), value)
self.assertTrue(self.cache._cache.ttl(key) < 0)
def test_set_expiration_first_expire_call(self): def test_set_expiration_first_expire_call(self):
key, value = self.cache.make_key('key'), 'value' key, value = self.cache.make_key('key'), 'value'
# bypass public set api so we don't set the expiration # bypass public set api so we don't set the expiration
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment