o |¿nhT ã@srdZddlmZddlmZmZddlmZddlm Z ddl m Z e e ƒZ Gdd „d eƒZGd d „d ee ƒZd S) zCement core cache module.é)Úabstractmethod)ÚAnyÚOptionalé)Ú Interface)ÚHandler)Úminimal_loggerc @s†eZdZdZGdd„dejƒZeddededefdd „ƒZ edded ed e e ddfd d „ƒZ edede fdd„ƒZeddd„ƒZdS)ÚCacheInterfacea This class defines the Cache Interface. Handlers that implement this interface must provide the methods and attributes defined below. In general, most implementations should sub-class from the provided :class:`CacheHandler` base class as a starting point. c@seZdZdZdZdS)zCacheInterface.MetazHandler meta-data.ÚcacheN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú interface©rrúI/usr/local/bin/dhwp/env/lib/python3.10/site-packages/cement/core/cache.pyÚMetasrNÚkeyÚfallbackÚreturncCódS)a Get the value for a key in the cache. If the key does not exist or the key/value in cache is expired, this functions must return ``fallback`` (which in turn must default to ``None``). Args: key (str): The key of the value stored in cache Keyword Args: fallback: Optional value that is returned if the cache is expired or the key does not exist. Returns: Unknown: Whatever the value is in the cache, or the ``fallback`` Nr)ÚselfrrrrrÚgetszCacheInterface.getÚvalueÚtimecCr)aÍ Set the key/value in the cache for a set amount of ``time``. Args: key (str): The key of the value to store in cache value (unknown): The value of that key to store in cache Keyword Args: time (int): A one-off expire time in seconds (or ``None``. If no time is given, then a default value is used (determined by the implementation). Returns: None Nr)rrrrrrrÚset2szCacheInterface.setcCr)zæ Deletes a key/value from the cache. Args: key: The key in the cache to delete Returns: bool: ``True`` if the key is successfully deleted, ``False`` otherwise Nr)rrrrrÚdeleteEs zCacheInterface.deletecCr)z2 Clears all data from the cache. Nr)rrrrÚpurgeTszCacheInterface.purge)N)rN)r r r rrrrÚstrrrrÚintrÚboolrrrrrrr s"r c@s"eZdZdZGdd„dejƒZdS)Ú CacheHandlerz( Cache handler implementation. c@s eZdZdS)zCacheHandler.MetaN)r r r rrrrrcsrN)r r r rrrrrrrr!]sr!N)rÚabcrÚtypingrrÚcore.interfacerÚ core.handlerrÚ utils.miscrr ÚLOGr r!rrrrÚs    Q