o
    ]f                     @   s2   d Z ddlmZ ddlmZ G dd deeZdS )z
    flask_caching.backends.uwsgicache
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    The uWSGI caching backend.

    :copyright: (c) 2018 by Peter Justin.
    :copyright: (c) 2010 by Thadeus Burgess.
    :license: BSD, see LICENSE for more details.
    )
UWSGICache)	BaseCachec                   @   s&   e Zd ZdZd	ddZedd ZdS )
r   ak  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 use the first cache instance initialized.
        If the cache is in the same instance as the werkzeug app,
        you only have to provide the name of the cache.
    ,   c              
   C   sj   t j| |d tj| ||d z	dd l}|| _W n ty) } ztd|d }~ww d|jvr3tdd S )N)default_timeout)cacher   r   z9uWSGI could not be imported, are you running under uWSGI?cache2zgYou must enable cache2 in uWSGI configuration: https://uwsgi-docs.readthedocs.io/en/latest/Caching.html)r   __init__CachelibUWSGICacheuwsgi_uwsgiImportErrorRuntimeErroropt)selfr   r   r   e r   Y/home/ubuntu/webapp/venv/lib/python3.10/site-packages/flask_caching/contrib/uwsgicache.pyr	       s,   

zUWSGICache.__init__c                 C   s*   | dd}|t|d | |i |S )NCACHE_UWSGI_NAMEr   )r   )getupdatedict)clsappconfigargskwargsuwsgi_cache_namer   r   r   factory7   s   zUWSGICache.factoryN)r   r   )__name__
__module____qualname____doc__r	   classmethodr   r   r   r   r   r      s
    
r   N)r"   cachelibr   r
   flask_caching.backends.baser   r   r   r   r   <module>   s    