File: //opt/alt/python37/lib/python3.7/site-packages/jsons/__pycache__/_cache.cpython-37.pyc
B
�P�e� � @ sT d Z ddlmZ ddlmZmZ ddlmZ G dd� d�Zed�dd �Z d
d� Z
dS )
zn
PRIVATE MODULE: do not import (from) it directly.
This module contains functionality for caching functions.
� )�deque)� lru_cache�update_wrapper)�Callablec @ s2 e Zd ZdZeg �Zdd� Zedd�dd� �ZdS ) �_Wrapperz�
A wrapper around a function that needs to be cached. This wrapper allows
for a single point from which cache can be cleared.
c C s || _ | j�| � d S )N)�wrapped� instances�append)�selfr � r �=/opt/alt/python37/lib/python3.7/site-packages/jsons/_cache.py�__init__ s z_Wrapper.__init__T)�typedc O s | j ||�S )N)r )r
�args�kwargsr r r �__call__ s z_Wrapper.__call__N) �__name__�
__module__�__qualname__�__doc__r r r
r r r r r r r s r )� decoratedc C s t | �}t|| d� |S )z�
Alternative for ``functools.lru_cache``. By decorating a function with
``cached``, you can clear the cache of that function by calling
``clear()``.
:param decorated: the decorated function.
:return: a wrapped function.
)�wrapperr )r r )r r r r r �cached s r c C s xt jD ]} | j�� qW dS )z\
Clear all cache of functions that were cached using ``cached``.
:return: None.
N)r r r �cache_clear)�wr r r �clear( s r N)r �collectionsr � functoolsr r �typingr r r r r r r r �<module> s