
    Ջg
                     B    d dl Z d dlZd dlmZ d dlmZ  G d de      Zy)    N)	BaseCache)UWSGISerializerc            
       0   e Zd ZdZ e       Z	 	 ddedefdZdede	j                  fdZdedefdZ	 dded
e	j                  de	j                  e   de	j                  e   fdZdded
e	j                  de	j                  e   defdZdefdZdedefdZy	)
UWSGICachea^  Implements the cache using uWSGI's caching framework.

    .. note::
        This class cannot be used when running under PyPy, because the uWSGI
        API implementation for PyPy is lacking the needed functionality.

    :param default_timeout: The default timeout in seconds.
    :param cache: The name of the caching instance to connect to, for
        example: mycache@localhost:3031, defaults to an empty string, which
        means uWSGI will cache in the local instance. If the cache is in the
        same instance as the werkzeug app, you only have to provide the name of
        the cache.
    default_timeoutcachec                     t        j                  | |       t        j                         dk(  rt	        d      	 dd l}|| _        || _        y # t        $ r}t	        d      |d }~ww xY w)NPyPyzFuWSGI caching does not work under PyPy, see the docs for more details.r   z9uWSGI could not be imported, are you running under uWSGI?)	r   __init__platformpython_implementationRuntimeErroruwsgi_uwsgiImportErrorr   )selfr   r   r   errs        A/var/www/html/venv/lib/python3.12/site-packages/cachelib/uwsgi.pyr   zUWSGICache.__init__   st    
 	41))+v5- 
	DK 
  	K	s   A 	A'A""A'keyreturnc                     | j                   j                  || j                        }|y | j                  j	                  |      S N)r   	cache_getr   
serializerloads)r   r   rvs      r   getzUWSGICache.get1   s9    [[""3

3:$$R((    c                 `    t        | j                  j                  || j                              S r   )boolr   	cache_delr   r   r   s     r   deletezUWSGICache.delete7   s"    DKK))#tzz:;;r   Nvaluetimeoutc                     | j                   j                  || j                  j                  |      | j	                  |      | j
                        }|S r   )r   cache_updater   dumps_normalize_timeoutr   )r   r   r$   r%   results        r   setzUWSGICache.set:   sI     ))OO!!%(##G,JJ	
 r   c           	          t        | j                  j                  || j                  j	                  |      | j                  |      | j                              S r   )r    r   	cache_setr   r(   r)   r   )r   r   r$   r%   s       r   addzUWSGICache.addE   sK    KK!!%%e,''0

	
 	
r   c                 ^    t        | j                  j                  | j                              S r   )r    r   cache_clearr   )r   s    r   clearzUWSGICache.clearO   s     DKK++DJJ788r   c                 R    | j                   j                  || j                        d uS r   )r   cache_existsr   r"   s     r   haszUWSGICache.hasR   s"    {{''TZZ8DDr   )i,   r   )__name__
__module____qualname____doc__r   r   intstrr   _tAnyr   r    r#   Optionalr+   r.   r1   r4    r   r   r   r      s     !"J  # 0)s )rvv )<# <$ < DH		!vv	02C0@		T		
s 
266 
BKK4D 
PT 
9t 9Es Et Er   r   )r   typingr<   cachelib.baser   cachelib.serializersr   r   r?   r   r   <module>rC      s!      # 0KE KEr   