ó
TR¹Nc           @   sF   d  Z  d d l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s   Base Cache class.iÿÿÿÿ(   t   ImproperlyConfiguredt   InvalidCacheBackendErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyR      s   t	   BaseCachec           B   s   e  Z d  „  Z d d „ Z d d „ Z d d „ Z d „  Z d „  Z d „  Z	 d d „ Z
 d d	 „ Z d
 „  Z d d „ Z d „  Z d „  Z RS(   c         C   sO   | j  d d ƒ } y t | ƒ } Wn t t f k
 rA d } n X| |  _ d  S(   Nt   timeouti,  (   t   gett   intt
   ValueErrort	   TypeErrort   default_timeout(   t   selft   paramsR   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   __init__	   s    
c         C   s
   t  ‚ d S(   s  
        Set a value in the cache if the key does not already exist. If
        timeout is given, that timeout will be used for the key; otherwise
        the default cache timeout will be used.

        Returns True if the value was stored, False otherwise.
        N(   t   NotImplementedError(   R   t   keyt   valueR   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   add   s    c         C   s
   t  ‚ d S(   s…   
        Fetch a given key from the cache. If the key does not exist, return
        default, which itself defaults to None.
        N(   R   (   R   R   t   default(    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyR      s    c         C   s
   t  ‚ d S(   s¡   
        Set a value in the cache. If timeout is given, that timeout will be
        used for the key; otherwise the default cache timeout will be used.
        N(   R   (   R   R   R   R   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   set"   s    c         C   s
   t  ‚ d S(   s@   
        Delete a key from the cache, failing silently.
        N(   R   (   R   R   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   delete)   s    c         C   sC   i  } x6 | D]. } |  j  | ƒ } | d k	 r | | | <q q W| S(   s/  
        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.
        N(   R   t   None(   R   t   keyst   dt   kt   val(    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   get_many/   s    c         C   s   |  j  | ƒ d k	 S(   sN   
        Returns True if the key is in the cache and has not expired.
        N(   R   R   (   R   R   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   has_key>   s    i   c         C   sF   | |  k r t  d | ƒ ‚ n  |  j | ƒ | } |  j | | ƒ | S(   ss   
        Add delta to value in the cache. If the key does not exist, raise a
        ValueError exception.
        s   Key '%s' not found(   R   R   R   (   R   R   t   deltat	   new_value(    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   incrD   s
    c         C   s   |  j  | | ƒ S(   sz   
        Subtract delta from value in the cache. If the key does not exist, raise
        a ValueError exception.
        (   R   (   R   R   R   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   decrO   s    c         C   s   |  j  | ƒ S(   sN   
        Returns True if the key is in the cache and has not expired.
        (   R   (   R   R   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   __contains__V   s    c         C   s4   x- | j  ƒ  D] \ } } |  j | | | ƒ q Wd S(   sM  
        Set a bunch of values in the cache at once from a dict of key/value
        pairs.  For certain backends (memcached), this is much more efficient
        than calling set() multiple times.

        If timeout is given, that timeout will be used for the key; otherwise
        the default cache timeout will be used.
        N(   t   itemsR   (   R   t   dataR   R   R   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   set_many_   s    	c         C   s"   x | D] } |  j  | ƒ q Wd S(   s²   
        Set a bunch of values in the cache at once.  For certain backends
        (memcached), this is much more efficient than calling delete() multiple
        times.
        N(   R   (   R   R   R   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   delete_manyk   s    c         C   s
   t  ‚ d S(   s+   Remove *all* values from the cache at once.N(   R   (   R   (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   cleart   s    N(   R   R   R   R   R   R   R   R   R   R   R   R   R    R#   R$   R%   (    (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyR      s   	
							N(   t   __doc__t   django.core.exceptionsR    R   t   objectR   (    (    (    sL   /home/panlixing/Python_Projects/gaeseries/django/core/cache/backends/base.pyt   <module>   s   