Current File : //proc/self/root/kunden/usr/lib/python3.9/site-packages/__pycache__/memcache.cpython-39.pyc |
a
^�Lb3� � @ s d Z ddlmZ ddlZddlmZ ddlZddlZddlZddl Z ddl
Z
ddlZddlZej
rlddlZnddlZdd� Zeadd� Ze�d �Zd
ZdZdZd
ZdZdZG dd� de�ZG dd� de�ZdZdZG dd� de j �Z!G dd� de"�Z#dd� Z$dS )a� client module for memcached (memory cache daemon)
Overview
========
See U{the MemCached homepage<http://www.danga.com/memcached>} for more
about memcached.
Usage summary
=============
This should give you a feel for how this module operates::
import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=0)
mc.set("some_key", "Some value")
value = mc.get("some_key")
mc.set("another_key", 3)
mc.delete("another_key")
mc.set("key", "1") # note that the key used for incr/decr must be
# a string.
mc.incr("key")
mc.decr("key")
The standard way to use memcache with a database is like this:
key = derive_key(obj)
obj = mc.get(key)
if not obj:
obj = backend_api.get(...)
mc.set(key, obj)
# we now have obj, and future passes through this code
# will use the object from the cache.
Detailed Documentation
======================
More detailed documentation is available in the L{Client} class.
� )�print_functionN)�BytesIOc C s t �| �d@ d? d@ pdS )Nl �� � i� � )�binascii�crc32)�key� r �,/usr/lib/python3.9/site-packages/memcache.py�cmemcache_hashD s r c C s
t jadS )z1Use the old python-memcache server hash function.N)r r �serverHashFunctionr r r r
�useOldServerHashFunctionI s r
s
[!-~�-�]+$z-Sean Reifschneider <jafo-memcached@tummy.com>z1.59z$Copyright (C) 2003 Danga Interactivez"Python Software Foundation License� i c @ s e Zd ZdS )�_ErrorN��__name__�
__module__�__qualname__r r r r
r a s r c @ s e Zd ZdS )�_ConnectionDeadErrorNr r r r r
r e s r � � c s e Zd ZdZdZdZdZdZdZdZ G dd � d e
�ZG d
d� de�ZG dd
� d
e�Z
G dd� de�ZG dd� de�ZG dd� de
�Zddejejejejddddeedddf� fdd� Zdd� Zdd� Zdd� Zd d!� Zdid"d#�Zd$d%� Zd&d'� Z d(d)� Z!d*d+� Z"d,d-� Z#d.d/� Z$d0d1� Z%d2d3� Z&d4d5� Z'djd7d8�Z(dkd9d:�Z)dld;d<�Z*dmd=d>�Z+dnd?d@�Z,dodAdB�Z-dpdCdD�Z.dqdEdF�Z/drdGdH�Z0dsdIdJ�Z1dtdKdL�Z2dudMdN�Z3dvdOdP�Z4dQdR� Z5dwdSdT�Z6dUdV� Z7dxdWdX�Z8dYdZ� Z9d[d\� Z:d]d^� Z;dyd_d`�Z<dzdadb�Z=d{dcdd�Z>dedf� Z?d|dgdh�Z@� ZAS )}�Clienta� Object representing a pool of memcache servers.
See L{memcache} for an overview.
In all cases where a key is used, the key can be either:
1. A simple hashable type (string, integer, etc.).
2. A tuple of C{(hashvalue, key)}. This is useful if you want
to avoid making this module calculate a hash value. You may
prefer, for example, to keep all of a given user's objects on
the same memcache server, so you could use the user's unique
id as the hash value.
@group Setup: __init__, set_servers, forget_dead_hosts,
disconnect_all, debuglog
@group Insertion: set, add, replace, set_multi
@group Retrieval: get, get_multi
@group Integers: incr, decr
@group Removal: delete, delete_multi
@sort: __init__, set_servers, forget_dead_hosts, disconnect_all,
debuglog,\ set, set_multi, add, replace, get, get_multi,
incr, decr, delete, delete_multi
r � � � r �
c @ s e Zd ZdS )zClient.MemcachedKeyErrorNr r r r r
�MemcachedKeyError� s r c @ s e Zd ZdS )zClient.MemcachedKeyLengthErrorNr r r r r
�MemcachedKeyLengthError� s r c @ s e Zd ZdS )z!Client.MemcachedKeyCharacterErrorNr r r r r
�MemcachedKeyCharacterError� s r c @ s e Zd ZdS )zClient.MemcachedKeyNoneErrorNr r r r r
�MemcachedKeyNoneError� s r c @ s e Zd ZdS )zClient.MemcachedKeyTypeErrorNr r r r r
�MemcachedKeyTypeError� s r c @ s e Zd ZdS )z#Client.MemcachedStringEncodingErrorNr r r r r
�MemcachedStringEncodingError� s r! r NFTc s� t t| ��� || _|| _|
| _|| _| �|� i | _|| _ | �
� || _|| _|| _
|| _|| _|| _|| _| | _|
| _| jdu r�t| _|| _| jdu r�t| _t� }z| j
|| jd�}d| _W n ty� d| _Y n0 dS )a� Create a new Client object with the given list of servers.
@param servers: C{servers} is passed to L{set_servers}.
@param debug: whether to display error messages when a server
can't be contacted.
@param pickleProtocol: number to mandate protocol used by
(c)Pickle.
@param pickler: optional override of default Pickler to allow
subclassing.
@param unpickler: optional override of default Unpickler to
allow subclassing.
@param pload: optional persistent_load function to call on
pickle loading. Useful for cPickle since subclassing isn't
allowed.
@param pid: optional persistent_id function to call on pickle
storing. Useful for cPickle since subclassing isn't allowed.
@param dead_retry: number of seconds before retrying a
blacklisted server. Default to 30 s.
@param socket_timeout: timeout in seconds for all calls to a
server. Defaults to 3 seconds.
@param cache_cas: (default False) If true, cas operations will
be cached. WARNING: This cache is not expired internally, if
you have a long-running process you will need to expire it
manually via client.reset_cas(), or the cache can grow
unlimited.
@param server_max_key_length: (default SERVER_MAX_KEY_LENGTH)
Data that is larger than this will not be sent to the server.
@param server_max_value_length: (default
SERVER_MAX_VALUE_LENGTH) Data that is larger than this will
not be sent to the server.
@param flush_on_reconnect: optional flag which prevents a
scenario that can cause stale data to be read: If there's more
than one memcached server and the connection to one is
interrupted, keys that mapped to that server will get
reassigned to another. If the first server comes back, those
keys will map to it again. If it still has its data, get()s
can read stale data that was overwritten on another
server. This flag is off by default for backwards
compatibility.
@param check_keys: (default True) If True, the key is checked
to ensure it is the correct length and composed of the right
characters.
N�ZprotocolTF)�superr �__init__�debug�
dead_retry�socket_timeout�flush_on_reconnect�set_servers�stats� cache_cas� reset_cas�do_check_key�pickleProtocol�pickler� unpickler�
compressor�decompressor�persistent_load�
persistent_id�server_max_key_length�SERVER_MAX_KEY_LENGTH�server_max_value_length�SERVER_MAX_VALUE_LENGTHr �picklerIsKeyword� TypeError)�self�serversr% r. r/ r0 r1 r2 Zpload�pidr5 r7 r&