Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incr() and decr() fail #7

Open
joshourisman opened this issue Aug 25, 2011 · 1 comment
Open

incr() and decr() fail #7

joshourisman opened this issue Aug 25, 2011 · 1 comment

Comments

@joshourisman
Copy link

I'm using django-newcache on top of memcached with python-memcache on Django 1.3. For some reason incr() and decr() always fail with a ValueError saying the key cannot be found, even though get() can find it just fine. Here's a copy and paste from the shell:

>>> cache.set('test', 0)
True
>>> cache.get('test')
0
>>> cache.incr('test')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/josho/.virtualenvs/faceuptoit/lib/python2.7/site-packages/newcache.py", line 210, in incr
    raise ValueError("Key '%s' not found" % (key,))
ValueError: Key 'test' not found
>>> cache.decr('test')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/josho/.virtualenvs/faceuptoit/lib/python2.7/site-packages/newcache.py", line 216, in decr
    raise ValueError("Key '%s' not found" % (key,))
ValueError: Key 'test' not found
>>> cache.get('test')
0
@joshourisman
Copy link
Author

Ah, this is due to the thundering herd protection. You need to pass herd=False to the set() method and then it will work.

This should probably be clearer in the documentation, I didn't expect (though perhaps I should have?) to have to read through the note at the end of the thundering herd mitigation section in order to figure this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant