
    hK                     6    S SK r " S S5      r " S S\5      rg)    Nc            
       $   \ rS rSrSrSS\4S jjrS\R                  \   S\4S jr	S\
S\R                  4S	 jrS\
S\4S
 jrS\
S\R                  \R                     4S jrS\
S\R"                  \
\R                  4   4S jr SS\
S\R                  S\R                  \   S\R                  \   4S jjrSS\
S\R                  S\R                  \   S\4S jjr SS\R"                  \
\R                  4   S\R                  \   S\R                  \R                     4S jjrS\
S\R                  \R                     4S jrS\
S\4S jrS\4S jrSS\
S\S\R                  \   4S jjrSS\
S\S\R                  \   4S jjrSrg)	BaseCache   a9  Baseclass for the cache systems.  All the cache systems implement this
API or a superset of it.

:param default_timeout: the default timeout (in seconds) that is used if
                        no timeout is specified on :meth:`set`. A timeout
                        of 0 indicates that the cache never expires.
default_timeoutc                     Xl         g Nr   )selfr   s     bC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\cachelib/base.py__init__BaseCache.__init__   s    .    timeoutreturnc                 $    Uc  U R                   nU$ r   r	   )r
   r   s     r   _normalize_timeoutBaseCache._normalize_timeout   s    ?**Gr   keyc                     g)zLook up key in the cache and return the value for it.

:param key: the key to be looked up.
:returns: The value if it exists and is readable, else ``None``.
N r
   r   s     r   getBaseCache.get   s     r   c                     g)zDelete `key` from the cache.

:param key: the key to delete.
:returns: Whether the key existed and has been deleted.
:rtype: boolean
Tr   r   s     r   deleteBaseCache.delete        r   keysc                 N    U Vs/ s H  o R                  U5      PM     sn$ s  snf )a  Returns a list of values for the given keys.
For each key an item in the list is created::

    foo, bar = cache.get_many("foo", "bar")

Has the same error handling as :meth:`get`.

:param keys: The function accepts multiple keys as positional
             arguments.
)r   )r
   r   ks      r   get_manyBaseCache.get_many&   s"     &**TT***s   "c                 D    [        [        XR                  " U6 5      5      $ )zLike :meth:`get_many` but return a dict::

    d = cache.get_dict("foo", "bar")
    foo = d["foo"]
    bar = d["bar"]

:param keys: The function accepts multiple keys as positional
             arguments.
)dictzipr!   )r
   r   s     r   get_dictBaseCache.get_dict3   s     CmmT2344r   Nvaluec                     g)a  Add a new key/value to the cache (overwrites value, if key already
exists in the cache).

:param key: the key to set
:param value: the value for the key
:param timeout: the cache timeout for the key in seconds (if not
                specified, it uses the default timeout). A timeout of
                0 indicates that the cache never expires.
:returns: ``True`` if key has been updated, ``False`` for backend
          errors. Pickling errors, however, will raise a subclass of
          ``pickle.PickleError``.
:rtype: boolean
Tr   r
   r   r(   r   s       r   setBaseCache.set?   s      r   c                     g)a  Works like :meth:`set` but does not overwrite the values of already
existing keys.

:param key: the key to set
:param value: the value for the key
:param timeout: the cache timeout for the key in seconds (if not
                specified, it uses the default timeout). A timeout of
                0 indicates that the cache never expires.
:returns: Same as :meth:`set`, but also ``False`` for already
          existing keys.
:rtype: boolean
Tr   r*   s       r   addBaseCache.addQ   s     r   mappingc                     / nUR                  5        H/  u  pEU R                  XEU5      (       d  M  UR                  U5        M1     U$ )am  Sets multiple keys and values from a mapping.

:param mapping: a mapping with the keys/values to set.
:param timeout: the cache timeout for the key in seconds (if not
                specified, it uses the default timeout). A timeout of
                0 indicates that the cache never expires.
:returns: A list containing all keys successfully set
:rtype: boolean
)itemsr+   append)r
   r0   r   set_keysr   r(   s         r   set_manyBaseCache.set_many`   s?     !--/JCxxG,,$ * r   c                 n    / nU H,  nU R                  U5      (       d  M  UR                  U5        M.     U$ )zDeletes multiple keys at once.

:param keys: The function accepts multiple keys as positional
             arguments.
:returns: A list containing all successfully deleted keys
:rtype: boolean
)r   r3   )r
   r   deleted_keysr   s       r   delete_manyBaseCache.delete_manyr   s8     C{{3##C(  r   c                     [        S5      e)zChecks if a key exists in the cache without returning it. This is a
cheap operation that bypasses loading the actual data on the backend.

:param key: the key to check
z%s doesn't have an efficient implementation of `has`. That means it is impossible to check whether a key exists without fully loading the key's data. Consider using `self.get` explicitly if you don't care about performance.)NotImplementedErrorr   s     r   hasBaseCache.has   s     ">
 	
r   c                     g)zClears the cache.  Keep in mind that not all caches support
completely clearing the cache.

:returns: Whether the cache has been cleared.
:rtype: boolean
Tr   )r
   s    r   clearBaseCache.clear   r   r   deltac                 p    U R                  U5      =(       d    SU-   nU R                  X5      (       a  U$ S$ )a  Increments the value of a key by `delta`.  If the key does
not yet exist it is initialized with `delta`.

For supporting caches this is an atomic operation.

:param key: the key to increment.
:param delta: the delta to add.
:returns: The new value or ``None`` for backend errors.
r   Nr   r+   r
   r   rB   r(   s       r   incBaseCache.inc   4     ##!u,,,u6$6r   c                 p    U R                  U5      =(       d    SU-
  nU R                  X5      (       a  U$ S$ )a  Decrements the value of a key by `delta`.  If the key does
not yet exist it is initialized with `-delta`.

For supporting caches this is an atomic operation.

:param key: the key to increment.
:param delta: the delta to subtract.
:returns: The new value or `None` for backend errors.
r   NrD   rE   s       r   decBaseCache.dec   rH   r   r	   )i,  r   )   )__name__
__module____qualname____firstlineno____doc__intr   _tOptionalr   strAnyr   boolr   Listr!   Dictr&   r+   r.   r5   r9   r=   r@   rF   rJ   __static_attributes__r   r   r   r   r      s   / /"++c*: s 
s rvv # $ +c +bggbffo +
5c 
5bggc266k&: 
5 DH!vv02C0@	T	$s 266 BKK4D PT   JNwwsBFF{+68kk#6F	$  
s 
t 
t 7s 73 7r{{3/? 77s 73 7r{{3/? 7 7r   r   c                   *    \ rS rSrSrS\S\4S jrSrg)	NullCache   zA cache that doesn't cache.  This can be useful for unit testing.

:param default_timeout: a dummy parameter that is ignored but exists
                        for API compatibility with other caches.
r   r   c                     g)NFr   r   s     r   r=   NullCache.has   s    r   r   N)	rM   rN   rO   rP   rQ   rU   rW   r=   rZ   r   r   r   r\   r\      s    s t r   r\   )typingrS   r   r\   r   r   r   <module>ra      s!    j7 j7Z	 r   