� L�g� ����ddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ej e ��Zd�Zd d�ZGd �d ��ZGd �d ��Ze��ZdS)�N)�deepcopy)�Dict��AIOCACHE_CACHES)� BaseCache)�InvalidCacheTypec���|�d��d}|�|���d��}tt||g���|��S)N�.�����)�fromlist)�split�rstrip�getattr� __import__)� class_path� class_name� module_names �`/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/aiocache/factory.py�_class_from_stringrsZ���!�!�#�&�&�r�*�J��#�#�J�/�/�6�6�s�;�;�K� �:�k�Z�L�A�A�A�:� N� N�N�c ��|�C|�d��}t|t��rt|��n|}|di|��}g}|�[|D]X}|�d��}t|t��rt|��n|}|�|di|�����Yt|t��rt|��n|}|d||d�|��}|S)N�class)� serializer�plugins�)�pop� isinstance�strr�append)�cacherr�kwargs�cls�plugins_instances�plugin�instances r� _create_cacher&s�����n�n�W�%�%��)3�C��)=�)=�F� ��%�%�%�3���S�&�&�:�&�&� ������ 4� 4�F��*�*�W�%�%�C�-7��S�-A�-A�J�$�S�)�)�)�s�C� � $� $�S�S�]�]�6�]�]� 3� 3� 3� 3�)3�E�3�)?�)?� J� �u� %� %� %�U�E��u�P� �4E�P�P��P�P�H� �Orc��eZdZdZedZejd��Zejd��Zefd�Z e d���Z e d���Z e d���Z d S) �Cachea� This class is just a proxy to the specific cache implementations like :class:`aiocache.SimpleMemoryCache`, :class:`aiocache.RedisCache` and :class:`aiocache.MemcachedCache`. It is the preferred method of instantiating new caches over using the backend specific classes. You can instatiate a new one using the ``cache_type`` attribute like: >>> from aiocache import Cache >>> Cache(Cache.REDIS) RedisCache (127.0.0.1:6379) If you don't specify anything, ``Cache.MEMORY`` is used. Only ``Cache.MEMORY``, ``Cache.REDIS`` and ``Cache.MEMCACHED`` types are allowed. If the type passed is invalid, it will raise a :class:`aiocache.exceptions.InvalidCacheType` exception. �memory�redis� memcachedc ���|rt|t��s@td�t t j���������|j|fi|��}|jdi|��|S)N�'Invalid cache type, you can only use {}r) � issubclassrr�format�listr�keys�__new__�__init__)r"� cache_classr!r%s rr2z Cache.__new__>s���� � �;� � B� B� �"�9�@�@��o�FZ�F\�F\�A]�A]�^�^��� �'�;�&�{�=�=�f�=�=�����#�#�F�#�#�#��rc��t|S�Nr)r"�schemes r�_get_cache_classzCache._get_cache_classGs ���v�&�&rc ��� |�|��S#t$rF}td�t t j��������|�d}~wwxYw)Nr-)r8�KeyErrorrr/r0rr1)r"r7�es r�get_scheme_classzCache.get_scheme_classKsq�� ��'�'��/�/� /��� � � �"�9�@�@��o�FZ�F\�F\�A]�A]�^�^���� ����� ���s�� A'�AA"�"A'c���tj�|��}ttj�|j����}t �|j��}|j r-|� |� |j ����|j r |j |d<|j r |j |d<|jr |j|d<t |fi|��S)a� Given a resource uri, return an instance of that cache initialized with the given parameters. An example usage: >>> from aiocache import Cache >>> Cache.from_url('memory://') <aiocache.backends.memory.SimpleMemoryCache object at 0x1081dbb00> a more advanced usage using queryparams to configure the cache: >>> from aiocache import Cache >>> cache = Cache.from_url('redis://localhost:10/1?pool_max_size=1') >>> cache RedisCache (localhost:10) >>> cache.db 1 >>> cache.pool_max_size 1 :param url: string identifying the resource uri of the cache to connect to �endpoint�port�password)�urllib�parse�urlparse�dict� parse_qsl�queryr(r<r7�path�update�parse_uri_path�hostnamer?r@)r"�url� parsed_urlr!r4s r�from_urlzCache.from_urlTs���.�\�*�*�3�/�/� ��f�l�,�,�Z�-=�>�>�?�?���,�,�Z�->�?�?� � �?� G� �M�M�+�4�4�Z�_�E�E� F� F� F� � � 5�!+�!4�F�:� � �?� -�'�_�F�6�N� � � 5�!+�!4�F�:� ��[�+�+�F�+�+�+rN)�__name__� __module__� __qualname__�__doc__r�MEMORY�get�REDIS� MEMCACHEDr2� classmethodr8r<rMrrrr(r(&s���������&�X� &�F� �O� �� (� (�E�#��#�K�0�0�I�!'������'�'��[�'�����[���&,�&,��[�&,�&,�&,rr(c��eZdZUddddid�iZeeeeeffed<d�Zded eeefd d fd �Z ded efd �Z defd�Z d�Z d�Z d�Zd S)� CacheHandler�defaultzaiocache.SimpleMemoryCacherz%aiocache.serializers.StringSerializer)r r�_configc��i|_dSr6)�_caches��selfs rr3zCacheHandler.__init__�s ���� � � r�alias�config�returnNc��||j|<dS)a� Add a cache to the current config. If the key already exists, it will overwrite it:: >>> caches.add('default', { 'cache': "aiocache.SimpleMemoryCache", 'serializer': { 'class': "aiocache.serializers.StringSerializer" } }) :param alias: The alias for the cache :param config: Mapping containing the cache configuration N)rZ�r^r_r`s r�addzCacheHandler.add�s��%�� �U���rc�� |j|S#t$rYnwxYw|�|��}tdit |����}||j|<|S)a  Retrieve cache identified by alias. Will return always the same instance If the cache was not instantiated yet, it will do it lazily the first time this is called. :param alias: str cache alias :return: cache instance r)r\r:�get_alias_configr&r)r^r_r`r s rrSzCacheHandler.get�su�� ��<��&� &��� � � � �D� �����&�&�u�-�-���1�1��� 0� 0�1�1��#�� �U��� s � � �c �L�|�|��}tdii|�|���S)z�Create a new cache. You can use kwargs to pass extra parameters to configure the cache. :param alias: alias to pull configuration from :return: New cache instance r)rfr&)r^r_r!r`s r�createzCacheHandler.create�s6���&�&�u�-�-���4�4�3�&�3�F�3�4�4�4rc��|���}||vr"td�|�����||S)NzzCould not find config for '{0}', ensure you include {0} when callingcaches.set_config specifying the config for that cache)� get_configr:r/rcs rrfzCacheHandler.get_alias_config�sL�����"�"�� �� � ��I�IO��PU����� � �e�}�rc�*�t|j��S)z6 Return copy of current stored config )rrZr]s rrjzCacheHandler.get_config�s���� �%�%�%rc��d|vrtd���|���D]}|j�|d���||_dS)a; Set (override) the default config for cache aliases from a dict-like structure. The structure is the following:: { 'default': { 'cache': "aiocache.SimpleMemoryCache", 'serializer': { 'class': "aiocache.serializers.StringSerializer" } }, 'redis_alt': { 'cache': "aiocache.RedisCache", 'endpoint': "127.0.0.10", 'port': 6378, 'serializer': { 'class': "aiocache.serializers.PickleSerializer" }, 'plugins': [ {'class': "aiocache.plugins.HitMissRatioPlugin"}, {'class': "aiocache.plugins.TimingPlugin"} ] } } 'default' key must always exist when passing a new config. Default configuration is:: { 'default': { 'cache': "aiocache.SimpleMemoryCache", 'serializer': { 'class': "aiocache.serializers.StringSerializer" } } } You can set your own classes there. The class params accept both str and class types. All keys in the config are optional, if they are not passed the defaults for the specified class will be used. If a config key already exists, it will be updated with the new values. rYzdefault config must be providedN)� ValueErrorr1r\rrZ)r^r`� config_names r� set_configzCacheHandler.set_config�s\��\ �F� "� "��>�?�?� ?�!�;�;�=�=� 0� 0�K� �L� � �[�$� /� /� /� /��� � � r)rNrOrPrZrr�object�__annotations__r3rdrSrhrfrjrorrrrXrX~s������� �1�"�$K�L� � �-�G�T�#�t�C��K�(�(� )�������%��%�d�3��;�&7�%�D�%�%�%�%�"��������( 5�C� 5� 5� 5� 5����&�&�&� 2�2�2�2�2rrX)NN)�loggingrA�copyr�typingr�aiocacher� aiocache.baser�aiocache.exceptionsr� getLoggerrN�loggerrr&r(rX�cachesrrr�<module>r{s������ � � � �������������$�$�$�$�$�$�#�#�#�#�#�#�0�0�0�0�0�0� �� �8� $� $��O�O�O� ����$U,�U,�U,�U,�U,�U,�U,�U,�p��������D ������r
Memory