관리-도구
편집 파일: redis_cache.cpython-38.pyc
U &?�fj � @ sX d dl mZ d dlmZmZ d dlmZ d dlmZ erDd dlm Z G dd� de�Z dS ) � )�annotations)�datetime�timezone)� TYPE_CHECKING)� BaseCache)�Redisc @ sn e Zd Zddd�dd�Zddd�d d �Zdddd dd�dd�Zddd�dd�Zdd�dd�Zdd�dd�ZdS )� RedisCachezRedis[bytes]�None)�conn�returnc C s || _ d S �N)r )�selfr � r �Y/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py�__init__ s zRedisCache.__init__�strzbytes | None)�keyr c C s | j �|�S r )r �get�r r r r r r s zRedisCache.getN�byteszint | datetime | None)r �value�expiresr c C sv |s| j �||� n^t|t�rbt�tj�}|jd kr@|jd d�}|| }| j � |t |�� �|� n| 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 zRedisCache.setc C s | j �|� d S r )r �deleter r r r r# % s zRedisCache.delete)r c C s | j �� D ]}| j �|� q dS )zIHelper for clearing all the keys in a database. Use with caution!N)r �keysr# r r r r �clear( s zRedisCache.clearc C s dS )z?Redis uses connection pooling, no need to close the connection.Nr )r r r r �close. s zRedisCache.close)N) �__name__� __module__�__qualname__r r r r# r% r&