U
    ;»{j¡  ã                   @  sr   d Z ddlmZ ddlmZ ddlmZmZmZ er@ddl	m	Z	 G dd„ dƒZ
G dd	„ d	e
ƒZG d
d„ de
ƒZdS )zb
The cache object API for implementing caches. The default is a thread
safe in-memory dictionary.
é    )Úannotations)ÚLock)ÚIOÚTYPE_CHECKINGÚMutableMapping)Údatetimec                   @  sP   e Zd Zdddœdd„Zddddd	d
œdd„Zdd	dœdd„Zd	dœdd„ZdS )Ú	BaseCacheÚstrúbytes | None©ÚkeyÚreturnc                 C  s
   t ƒ ‚d S ©N©ÚNotImplementedError©Úselfr   © r   ú?/tmp/pip-install-zsn1f9xv/pip/pip/_vendor/cachecontrol/cache.pyÚget   s    zBaseCache.getNÚbytesúint | datetime | NoneÚNone©r   ÚvalueÚexpiresr   c                 C  s
   t ƒ ‚d S r   r   ©r   r   r   r   r   r   r   Úset   s    zBaseCache.setc                 C  s
   t ƒ ‚d S r   r   r   r   r   r   Údelete   s    zBaseCache.delete)r   c                 C  s   d S r   r   )r   r   r   r   Úclose   s    zBaseCache.close)N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r      s
    ÿr   c                   @  sT   e Zd Zddddœdd„Zddd	œd
d„Zddddddœdd„Zddd	œdd„ZdS )Ú	DictCacheNz!MutableMapping[str, bytes] | Noner   )Ú	init_dictr   c                 C  s   t ƒ | _|pi | _d S r   )r   ÚlockÚdata)r   r$   r   r   r   Ú__init__$   s    zDictCache.__init__r	   r
   r   c                 C  s   | j  |d ¡S r   )r&   r   r   r   r   r   r   (   s    zDictCache.getr   r   r   c              	   C  s&   | j � | j ||i¡ W 5 Q R X d S r   )r%   r&   Úupdater   r   r   r   r   +   s    zDictCache.setc              	   C  s,   | j � || jkr| j |¡ W 5 Q R X d S r   )r%   r&   Úpopr   r   r   r   r   1   s    
zDictCache.delete)N)N)r    r!   r"   r'   r   r   r   r   r   r   r   r#   #   s
    ÿr#   c                   @  s2   e Zd ZdZddddœdd„Zddd	œd
d„ZdS )ÚSeparateBodyBaseCacheag  
    In this variant, the body is not stored mixed in with the metadata, but is
    passed in (as a bytes-like object) in a separate call to ``set_body()``.

    That is, the expected interaction pattern is::

        cache.set(key, serialized_metadata)
        cache.set_body(key)

    Similarly, the body should be loaded separately via ``get_body()``.
    r	   r   r   )r   Úbodyr   c                 C  s
   t ƒ ‚d S r   r   )r   r   r+   r   r   r   Úset_bodyD   s    zSeparateBodyBaseCache.set_bodyzIO[bytes] | Noner   c                 C  s
   t ƒ ‚dS )z6
        Return the body as file-like object.
        Nr   r   r   r   r   Úget_bodyG   s    zSeparateBodyBaseCache.get_bodyN)r    r!   r"   Ú__doc__r,   r-   r   r   r   r   r*   7   s   r*   N)r.   Ú
__future__r   Ú	threadingr   Útypingr   r   r   r   r   r#   r*   r   r   r   r   Ú<module>   s   