#6462 closed (invalid)
memcached cache.get_many() is not doing what the Docstring says
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
Severity: | Keywords: | cache, memcached, get_many | |
Cc: | dcramer@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Cache.get_many()'s DOCSTRING states:
"""
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values.
Returns a dict mapping each key in keys to its value. If the given
key is missing, it will be missing from the response dict.
"""
Which basically isn't implemented, at least for memcached backend:
def get_many(self, keys): """ Fetch a bunch of keys from the cache. For certain backends (memcached, pgsql) this can be *much* faster when fetching multiple values. Returns a dict mapping each key in keys to its value. If the given key is missing, it will be missing from the response dict. """ d = {} for k in keys: val = self.get(k) if val is not None: d[k] = val return d
This simply uses cache.get() for retrieving objects from the (memcached) cache. The DOCSTRING simply is not true.
Cache.get_many(("a", "b")) isn't faster than calling cache.get() twice.
Change History (3)
comment:1 by , 17 years ago
Cc: | added |
---|
comment:2 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
reporter looked in wrong file, memcached backend is properly using get_multi()
from the memcache lib
comment:3 by , 17 years ago
Sorry for this stupid ticket, I simply didn't look properly at the memcached backend. Somehow missed the get_many definition there.
You will also find that get_many, or multi_get or whatever it is, does not return a list of keys, thus the support of this may need to be changed in the other cache backends.
Being as it is, this functionality should either not be supported, or should use memcache's get many methods.