Hasher Routines¶
-
class
memcached2.HasherBase¶ Turn memcache keys into hashes, for use in server selection.
Normally, the python-memcached2 classes will automatically select a hasher to use. However, for special circumstances you may wish to use a different hasher or develop your own.
This is an abstract base class, here largely for documentation purposes. Hasher sub-classes such as
HasherZeroandHasherCMemcache, implement a hash method which does all the work.See
hash()for details of implementing a subclass.-
hash(key)¶ Hash a key into a number.
This must persistently turn a string into the same value. That value is used to determine which server to use for this key.
Parameters: key (str) – memcache key Returns: int – Hashed version of key.
-
-
class
memcached2.HasherZero¶ Hasher that always returns 0, useful only for
SelectorFirst.-
hash(key)¶ See
memcached2.HasherBase.hash()for details of this function.
-
-
class
memcached2.HasherCMemcache¶ Hasher compatible with the C memcache hash function.
-
hash(key)¶ See
memcached2.HasherBase.hash()for details of this function.
-