Skip to content

Instantly share code, notes, and snippets.

@cshoe
Created January 25, 2013 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cshoe/4637547 to your computer and use it in GitHub Desktop.
Save cshoe/4637547 to your computer and use it in GitHub Desktop.
In [1]: from django.core.cache import cache
In [2]: key = 'blah'
In [3]: cache.incr('blah')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-154660d05ec4> in <module>()
----> 1 cache.incr('blah')
/Users/shoe/dev/envs/rdb/lib/python2.6/site-packages/django/core/cache/backends/locmem.py in incr(self, key, delta, version)
82 value = self.get(key, version=version)
83 if value is None:
---> 84 raise ValueError("Key '%s' not found" % key)
85 new_value = value + delta
86 key = self.make_key(key, version=version)
ValueError: Key 'blah' not found
In [4]: cache.set('blah', 1, 20)
In [5]: cache.incr('blah')
Out[5]: 2
In [6]: cache.incr('blah')
Out[6]: 3
In [7]: cache.incr('blah')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-7-154660d05ec4> in <module>()
----> 1 cache.incr('blah')
/Users/shoe/dev/envs/rdb/lib/python2.6/site-packages/django/core/cache/backends/locmem.py in incr(self, key, delta, version)
82 value = self.get(key, version=version)
83 if value is None:
---> 84 raise ValueError("Key '%s' not found" % key)
85 new_value = value + delta
86 key = self.make_key(key, version=version)
ValueError: Key 'blah' not found
In [8]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment