Format: application/x-python-code
1 o
2
3 2'h� � @ sH d dl Z d dlZd dlmZ d dlmZ e �d�jZG dd� de�Z dS )� N)�time)� BaseCachez[^\x00-\x21\xff]{1,250}$c
4 @ s� e Zd ZdZ d/dejdedeje fdd�Z d ed
5 efdd�Z
6 d
7 eje d
8 efdd�Zd ed
9 ejfdd�Zded
10 ej
11 eejf fdd�Zd0d edejd
12 eje d
13 efdd�Z d0d edejd
14 eje d
15 eje fdd�Zded
16 ejej fdd�Z d0dej
17 eejf d
18 eje d
19 ejej fdd�Zd ed
20 efdd �Zded
21 ejej fd!d"�Zd ed
22 efd#d$�Zd
23 efd%d&�Zd1d ed(ed
24 eje fd)d*�Zd1d ed(ed
25 eje fd+d,�Zdejd
26 ejfd-d.�ZdS )2�MemcachedCachea� A cache that uses memcached as backend.
27
28 The first argument can either be an object that resembles the API of a
29 :class:`memcache.Client` or a tuple/list of server addresses. In the
30 event that a tuple/list is passed, Werkzeug tries to import the best
31 available memcache library.
32
33 This cache looks into the following packages/modules to find bindings for
34 memcached:
35
36 - ``pylibmc``
37 - ``google.appengine.api.memcached``
38 - ``memcached``
39 - ``libmc``
40
41 Implementation notes: This cache backend works around some limitations in
42 memcached to simplify the interface. For example unicode keys are encoded
43 to utf-8 on the fly. Methods such as :meth:`~BaseCache.get_dict` return
44 the keys in the same format as passed. Furthermore all get methods
45 silently ignore key errors to not cause problems when untrusted user data
46 is passed to the get methods which is often the case in web applications.
47
48 :param servers: a list or tuple of server addresses or alternatively
49 a :class:`memcache.Client` or a compatible client.
50 :param default_timeout: the default timeout that is used if no timeout is
51 specified on :meth:`~BaseCache.set`. A timeout of
52 0 indicates that the cache never expires.
53 :param key_prefix: a prefix that is added before all keys. This makes it
54 possible to use the same memcached server for different
55 applications. Keep in mind that
56 :meth:`~BaseCache.clear` will also clear keys with a
57 different prefix.
58 N�, �servers�default_timeout�
59 key_prefixc C s` t �| |� |d u st|ttf�r(|d u rdg}| �|�| _| jd u r'td��n|| _|| _d S )Nz127.0.0.1:11211zno memcache module found) r �__init__�
60 isinstance�list�tuple�import_preferred_memcache_lib�_client�RuntimeErrorr )�selfr r r � r �HC:\Users\shubh\Videos\agent\nova\Lib\site-packages\cachelib/memcached.pyr . s
61 �
62 zMemcachedCache.__init__�key�returnc C s | j r| j | }|S �N)r �r r r r r �_normalize_keyB s
63 zMemcachedCache._normalize_key�timeoutc C s&