Code

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#6462 closed (invalid)

memcached cache.get_many() is not doing what the Docstring says

Reported by: panni@… Owned by: nobody
Component: Core (Cache system) Version: master
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: UI/UX:

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.

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by dcramer

  • Cc dcramer@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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.

comment:2 Changed 6 years ago by Collin Grady <cgrady@…>

  • Resolution set to invalid
  • Status changed from new to closed

reporter looked in wrong file, memcached backend is properly using get_multi() from the memcache lib

comment:3 Changed 6 years ago by panni@…

Sorry for this stupid ticket, I simply didn't look properly at the memcached backend. Somehow missed the get_many definition there.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.