o
    uvXj™
  ã                   @   sD   d dl mZ d dlmZmZmZ d dlmZ dZG dd„ deƒZ	dS )é    )Úsettings)ÚCreateErrorÚSessionBaseÚUpdateError)Úcacheszdjango.contrib.sessions.cachec                       sj   e Zd ZdZeZd‡ fdd„	Zedd„ ƒZdd„ Z	d	d
„ Z
ddd„Zdd„ Zddd„Zedd„ ƒZ‡  ZS )ÚSessionStorez&
    A cache-based session store.
    Nc                    s   t tj | _tƒ  |¡ d S ©N)r   r   ÚSESSION_CACHE_ALIASÚ_cacheÚsuperÚ__init__©ÚselfÚsession_key©Ú	__class__© úc/var/www/html/myproject/venv/lib/python3.10/site-packages/django/contrib/sessions/backends/cache.pyr      s   zSessionStore.__init__c                 C   s   | j |  ¡  S r   )Úcache_key_prefixÚ_get_or_create_session_key)r   r   r   r   Ú	cache_key   s   zSessionStore.cache_keyc                 C   s@   z	| j  | j¡}W n ty   d }Y nw |d ur|S d | _i S r   )r
   Úgetr   Ú	ExceptionÚ_session_key)r   Úsession_datar   r   r   Úload   s   ýzSessionStore.loadc              	   C   sN   t dƒD ]}|  ¡ | _z| jdd� W n	 ty   Y qw d| _ d S tdƒ‚)Ni'  T)Úmust_createzOUnable to create a new session key. It is likely that the cache is unavailable.)ÚrangeÚ_get_new_session_keyr   Úsaver   ÚmodifiedÚRuntimeError)r   Úir   r   r   Úcreate$   s   
ÿÿzSessionStore.createFc                 C   sn   | j d u r	|  ¡ S |r| jj}n| j | j¡d ur| jj}nt‚|| j| j|d�|  	¡ ƒ}|r3|s5t
‚d S d S )N)Úno_load)r   r#   r
   Úaddr   r   Úsetr   Ú_get_sessionÚget_expiry_ager   )r   r   ÚfuncÚresultr   r   r   r   6   s   



þÿzSessionStore.savec                 C   s   t |ƒo| j| | jv S r   )Úboolr   r
   r   r   r   r   ÚexistsE   s   zSessionStore.existsc                 C   s2   |d u r| j d u rd S | j }| j | j| ¡ d S r   )r   r
   Údeleter   r   r   r   r   r-   H   s
   
zSessionStore.deletec                 C   s   d S r   r   )Úclsr   r   r   Úclear_expiredO   s   zSessionStore.clear_expiredr   )F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
KEY_PREFIXr   r   Úpropertyr   r   r#   r   r,   r-   Úclassmethodr/   Ú__classcell__r   r   r   r   r   
   s    


r   N)
Údjango.confr   Ú%django.contrib.sessions.backends.baser   r   r   Údjango.core.cacher   r4   r   r   r   r   r   Ú<module>   s
    