o
    Vh^                     @  sX   d dl mZ d dlmZmZ d dlmZ d dlmZ er"d dlm	Z	 G dd deZ
dS )	    )annotations)datetimetimezone)TYPE_CHECKING)	BaseCache)Redisc                   @  sL   e Zd ZdddZdd
dZ	ddddZdddZdddZdddZdS )
RedisCacheconnRedis[bytes]returnNonec                 C  s
   || _ d S N)r	   )selfr	    r   s/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/cachecontrol/caches/redis_cache.py__init__   s   
zRedisCache.__init__keystrbytes | Nonec                 C  s   | j |S r   )r	   getr   r   r   r   r   r      s   zRedisCache.getNvaluebytesexpiresint | datetime | Nonec                 C  sz   |s| j || d S t|tr3ttj}|jd u r!|jd d}|| }| j 	|t
| | d S | j 	||| d S )N)tzinfo)r	   set
isinstancer   nowr   utcr   replacesetexinttotal_seconds)r   r   r   r   now_utcdeltar   r   r   r      s   

zRedisCache.setc                 C  s   | j | d S r   )r	   deleter   r   r   r   r&   %   s   zRedisCache.deletec                 C  s    | j  D ]}| j | qdS )zIHelper for clearing all the keys in a database. Use with
        caution!N)r	   keysr&   r   r   r   r   clear(   s   zRedisCache.clearc                 C  s   dS )z?Redis uses connection pooling, no need to close the connection.Nr   )r   r   r   r   close.   s   zRedisCache.close)r	   r
   r   r   )r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   )	__name__
__module____qualname__r   r   r   r&   r(   r)   r   r   r   r   r      s    



r   N)
__future__r   r   r   typingr   cachecontrol.cacher   redisr   r   r   r   r   r   <module>   s   