Skip to content

Commit

Permalink
Fixed #16533 -- Stopped the memcache cache backend from raising an ex…
Browse files Browse the repository at this point in the history
…ception if the timeout value isn't an integer. Thanks, Jeff Balogh.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16556 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jezdez committed Jul 29, 2011
1 parent 4f50d24 commit db594f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/core/cache/backends/memcached.py
Expand Up @@ -46,7 +46,7 @@ def _get_memcache_timeout(self, timeout):
# #
# This means that we have to switch to absolute timestamps. # This means that we have to switch to absolute timestamps.
timeout += int(time.time()) timeout += int(time.time())
return timeout return int(timeout)


def add(self, key, value, timeout=0, version=None): def add(self, key, value, timeout=0, version=None):
key = self.make_key(key, version=version) key = self.make_key(key, version=version)
Expand Down
5 changes: 5 additions & 0 deletions tests/regressiontests/cache/tests.py
Expand Up @@ -408,6 +408,11 @@ def test_long_timeout(self):
self.assertEqual(self.cache.get('key3'), 'sausage') self.assertEqual(self.cache.get('key3'), 'sausage')
self.assertEqual(self.cache.get('key4'), 'lobster bisque') 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): def perform_cull_test(self, initial_count, final_count):
"""This is implemented as a utility method, because only some of the backends """This is implemented as a utility method, because only some of the backends
implement culling. The culling algorithm also varies slightly, so the final implement culling. The culling algorithm also varies slightly, so the final
Expand Down

0 comments on commit db594f9

Please sign in to comment.