Format: application/x-python-code
⬇ Download File (2.9 KB)
   1  o
   2  
   3  2'h
   4  �@s<ddlZddlZddlmZddlmZGdd�de�ZdS)�N)�	BaseCache)�UWSGISerializerc
   5  @s�eZdZdZe�Z		ddedefdd�Zded	e	j
   6  fd
   7  d�Zded	efdd
   8  �Z
   9  	ddede	j
  10  de	jed	e	jefdd�Zddede	j
  11  de	jed	efdd�Zd	efdd�Zded	efdd�ZdS)�
  12  UWSGICachea^Implements the cache using uWSGI's caching framework.
  13  
  14      .. note::
  15          This class cannot be used when running under PyPy, because the uWSGI
  16          API implementation for PyPy is lacking the needed functionality.
  17  
  18      :param default_timeout: The default timeout in seconds.
  19      :param cache: The name of the caching instance to connect to, for
  20          example: mycache@localhost:3031, defaults to an empty string, which
  21          means uWSGI will cache in the local instance. If the cache is in the
  22          same instance as the werkzeug app, you only have to provide the name of
  23          the cache.
  24      �,��default_timeout�cachec
  25  Cs`t�||�t��dkrtd��z	ddl}||_Wnty*}ztd�|�d}~ww||_dS)N�PyPyzFuWSGI caching does not work under PyPy, see the docs for more details.rz9uWSGI could not be imported, are you running under uWSGI?)	r�__init__�platform�python_implementation�RuntimeError�uwsgi�_uwsgi�ImportErrorr)�selfrrr�err�r�DC:\Users\shubh\Videos\agent\nova\Lib\site-packages\cachelib/uwsgi.pyr
  26  s"�
  27  ����
  28  zUWSGICache.__init__�key�returncCs(|j�||j�}|durdS|j�|�S�N)r�	cache_getr�
  29  serializer�loads)rr�rvrrr�get1szUWSGICache.getcCst|j�||j��Sr)�boolrZ	cache_delr�rrrrr�delete7�zUWSGICache.deleteN�value�timeoutcCs&|j�||j�|�|�|�|j�}|Sr)rZcache_updater�dumps�_normalize_timeoutr)rrr!r"�resultrrr�set:s
  30  �zUWSGICache.setcCs&t|j�||j�|�|�|�|j��Sr)rrZ	cache_setrr#r$r)rrr!r"rrr�addEs
  31  ��zUWSGICache.addcCst|j�|j��Sr)rr�cache_clearr)rrrr�clearOszUWSGICache.clearcCs|j�||j�duSr)rZcache_existsrrrrr�hasRr zUWSGICache.has)rrr)�__name__�
  32  __module__�__qualname__�__doc__rr�int�strr
  33  �_t�Anyrrr�Optionalr&r'r)r*rrrrrs2��
  34  �����
  35  �$
  36  r)r�typingr1Z
  37  cachelib.baserZcachelib.serializersrrrrrr�<module>s
  38