HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/cachelib/__pycache__/base.cpython-310.pyc
o

!we9�@s*ddlZGdd�d�ZGdd�de�ZdS)�Nc
@s�eZdZdZd)defdd�Zdejedefdd	�Zd
e	dej
fdd�Zd
e	defd
d�Z
de	dejej
fdd�Zde	deje	ej
ffdd�Z	d*d
e	dej
dejedejefdd�Zd*d
e	dej
dejedefdd�Z	d*deje	ej
fdejedejej
fdd�Zde	dejej
fdd�Zd
e	defdd �Zdefd!d"�Zd+d
e	d$edejefd%d&�Zd+d
e	d$edejefd'd(�ZdS),�	BaseCacheaMBaseclass 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_timeoutcCs
||_dS�N�r)�selfr�r�F/home/arjun/projects/env/lib/python3.10/site-packages/cachelib/base.py�__init__
s
zBaseCache.__init__�timeout�returncCs|dur|j}|Srr)rrrrr	�_normalize_timeoutszBaseCache._normalize_timeout�keycC�dS)z�Look 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``.
        Nr�rrrrr	�getsz
BaseCache.getcCr)z�Delete `key` from the cache.

        :param key: the key to delete.
        :returns: Whether the key existed and has been deleted.
        :rtype: boolean
        Trrrrr	�delete�zBaseCache.delete�keyscs�fdd�|D�S)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.
        csg|]}��|��qSr)r)�.0�k�rrr	�
<listcomp>1sz&BaseCache.get_many.<locals>.<listcomp>r�rrrrr	�get_many&szBaseCache.get_manycGstt||j|���S)z�Like :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�ziprrrrr	�get_dict3s
zBaseCache.get_dictN�valuecCr)akAdd 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�rrrrrrr	�set?sz
BaseCache.setcCr)aWorks 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
        Trrrrr	�addQs
z
BaseCache.add�mappingcCs2g}|��D]\}}|�|||�r|�|�q|S)a�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 sucessfuly set
        :rtype: boolean
        )�itemsr �append)rr"r�set_keysrrrrr	�set_many`s
�zBaseCache.set_manycGs&g}|D]}|�|�r|�|�q|S)z�Deletes multiple keys at once.

        :param keys: The function accepts multiple keys as positional
                     arguments.
        :returns: A list containing all sucessfuly deleted keys
        :rtype: boolean
        )rr$)rr�deleted_keysrrrr	�delete_manyrs

�zBaseCache.delete_manycCstd��)z�Checks 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.)�NotImplementedErrorrrrr	�has�s�z
BaseCache.hascCr)z�Clears the cache.  Keep in mind that not all caches support
        completely clearing the cache.

        :returns: Whether the cache has been cleared.
        :rtype: boolean
        Trrrrr	�clear�rzBaseCache.clear��deltacCs&|�|�pd|}|�||�r|SdS)aHIncrements 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.
        rN�rr �rrr-rrrr	�inc��
z
BaseCache.inccCs&|�|�pd|}|�||�r|SdS)aLDecrements 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.
        rNr.r/rrr	�dec�r1z
BaseCache.dec)rr)r,)�__name__�
__module__�__qualname__�__doc__�intr
�_t�Optionalr
�str�Anyr�boolr�Listr�Dictrr r!r&r(r*r+r0r2rrrr	rs@	

����
�$���

�
	"
rc@s"eZdZdZdedefdd�ZdS)�	NullCachez�A 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.
    rrcCr)NFrrrrr	r*�sz
NullCache.hasN)r3r4r5r6r:r<r*rrrr	r?�sr?)�typingr8rr?rrrr	�<module>s.