�
<��g�
� �B � d dl Z d dlmZ d dlmZ G d� de� � ZdS )� N)�MutableMapping)� lru_cachec �P � e Zd ZdZ d
d�Zd� Zd� Zd� Zd� Zd � Z d
� Z
d� Zd� ZdS )�DirCachea�
Caching of directory listings, in a structure like::
{"path0": [
{"name": "path0/file0",
"size": 123,
"type": "file",
...
},
{"name": "path0/file1",
},
...
],
"path1": [...]
}
Parameters to this class control listing expiry or indeed turn
caching off
TNc � � � i � _ i � _ |r# t |dz � � � fd�� � � _ |� _ |� _ |� _ dS )a
Parameters
----------
use_listings_cache: bool
If False, this cache never returns items, but always reports KeyError,
and setting items has no effect
listings_expiry_time: int or float (optional)
Time in seconds that a listing is considered valid. If None,
listings do not expire.
max_paths: int (optional)
The number of most recent listings that are considered valid; 'recent'
refers to when the entry was set.
� c �: �� �j � | d � � S �N)�_cache�pop)�key�selfs ��_/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fsspec/dircache.py�<lambda>z#DirCache.__init__.<locals>.<lambda>3 s �� �4�;�?�?�3�PT�;U�;U� � N)r �_timesr �_q�use_listings_cache�listings_expiry_time� max_paths)r r r r �kwargss ` r �__init__zDirCache.__init__ s^ �� �* ������� W�.�i� �A�
�.�.�/U�/U�/U�/U�V�V�D�G�"4���$8��!�"����r c �� � | j �A| j � |d� � t j � � z
| j k r| j |= | j r| � |� � | j | S )Nr )r r �get�timer r r �r �items r �__getitem__zDirCache.__getitem__8 sg � ��$�0��{���t�Q�'�'�$�)�+�+�5��9R�8R�R�R��K��%��>� ��G�G�D�M�M�M��{�4� � r c �8 � | j � � � d S r
)r �clear�r s r r zDirCache.clear@ s � ���������r c �* � t | j � � S r
)�lenr r! s r �__len__zDirCache.__len__C s � ��4�;���r c �: � | | dS # t $ r Y dS w xY w)NTF)�KeyErrorr s r �__contains__zDirCache.__contains__F s7 � � ���J�J��4��� � � ��5�5� ���s � �
�c � � | j sd S | j r| � |� � || j |<