I opened a PR that adds optional support for default keyword argument in get() method: #158
This is due to a bug I've found in one of the projects I work for, that's Django based. We've noticed that using django's MemcachedCache backend class makes it impossible to save None into the cache without the cache framework thinking that no key is available. E.g.:
With django-redis RedisCache:
>>> cache.set('key', None, 10000)
True
>>> cache.get('key', default=123)
None
With django's MemcachedCache (issue is seen here, get() should return None):
>>> from django.core.cache.backends.memcached import MemcachedCache
>>> mc1 = MemcachedCache('127.0.0.1', {})
>>> mc1.set('key', None, timeout=3600)
>>> mc1.get('key', default=123)
123
PylibMC (an alternative to python-memcached) supports the default param correctly (although it's Django backend is also broken). If this issue gets fixed, I'll push a PR to django to use the new capabilities correctly.
The PR I mentioned adds support for the default keywords and makes it possible for someone to retrieve None from the backend knowing if he set it there explicitly, or if the key is simply missing.
I opened a PR that adds optional support for
defaultkeyword argument inget()method: #158This is due to a bug I've found in one of the projects I work for, that's Django based. We've noticed that using django's
MemcachedCachebackend class makes it impossible to saveNoneinto the cache without the cache framework thinking that no key is available. E.g.:With django-redis
RedisCache:With django's
MemcachedCache(issue is seen here,get()should returnNone):PylibMC (an alternative to python-memcached) supports the default param correctly (although it's Django backend is also broken). If this issue gets fixed, I'll push a PR to django to use the new capabilities correctly.
The PR I mentioned adds support for the default keywords and makes it possible for someone to retrieve
Nonefrom the backend knowing if he set it there explicitly, or if the key is simply missing.