summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/core/cache/backends/memcached.py2
-rw-r--r--tests/regressiontests/cache/tests.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
index 1e1d97ed35..aa1b4513c0 100644
--- a/django/core/cache/backends/memcached.py
+++ b/django/core/cache/backends/memcached.py
@@ -46,7 +46,7 @@ class BaseMemcachedCache(BaseCache):
#
# This means that we have to switch to absolute timestamps.
timeout += int(time.time())
- return timeout
+ return int(timeout)
def add(self, key, value, timeout=0, version=None):
key = self.make_key(key, version=version)
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
index afb5a15b41..6a5201ffeb 100644
--- a/tests/regressiontests/cache/tests.py
+++ b/tests/regressiontests/cache/tests.py
@@ -408,6 +408,11 @@ class BaseCacheTests(object):
self.assertEqual(self.cache.get('key3'), 'sausage')
self.assertEqual(self.cache.get('key4'), 'lobster bisque')
+ def test_float_timeout(self):
+ # Make sure a timeout given as a float doesn't crash anything.
+ self.cache.set("key1", "spam", 100.2)
+ self.assertEqual(self.cache.get("key1"), "spam")
+
def perform_cull_test(self, initial_count, final_count):
"""This is implemented as a utility method, because only some of the backends
implement culling. The culling algorithm also varies slightly, so the final