a2Z퇌dZddlmZddlmZ ddlmZn #e$rdZYnwxYwddlmZm Z m Z ddl m Z Gd d eZ d S) -Django-compatible disk and file backed cache.)wraps) BaseCache)DEFAULT_TIMEOUTi,)ENOVAL args_to_key full_name) FanoutCacheceZdZdZfdZedZdZd dZdZ e dddd fd Z d!d Z d d Z e dddd fd Ze dd fdZ d"dZd#dZd$dZd$dZd dZdZd%dZdZdZdZdZdZdZe fdZde ddddfdZxZS)& DjangoCacherct||dd}|dd}|di}t|||fi||_dS)zInitialize DjangoCache instance. :param str directory: cache directory :param dict params: cache parameters SHARDSDATABASE_TIMEOUTg{Gz?OPTIONSN)super__init__getr _cache)self directoryparamsshardstimeoutoptions __class__s u/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/diskcache/djangocache.pyrzDjangoCache.__init__sv    Ha((**/77**Y++!)VWHHHH c|jjS)zCache directory.)rrrs rrzDjangoCache.directory!s{$$rc6|j|S)zReturn Cache with given `name` in subdirectory. :param str name: subdirectory name for Cache :return: Cache with given name )rcachernames rr#zDjangoCache.cache&{  &&&rNc:|j||S)zReturn Deque with given `name` in subdirectory. :param str name: subdirectory name for Deque :param maxlen: max length (default None, no max) :return: Deque with given name )maxlen)rdeque)rr%r(s rr)zDjangoCache.deque/s{  f 555rc6|j|S)zReturn Index with given `name` in subdirectory. :param str name: subdirectory name for Index :return: Index with given name )rindexr$s rr+zDjangoCache.index9r&rFTc|||}||}|j||||||S)aSet a value in the cache if the key does not already exist. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. Return True if the value was stored, False otherwise. :param key: key for item :param value: value for item :param float timeout: seconds until the item expires (default 300 seconds) :param int version: key version number (default None, cache parameter) :param bool read: read value as bytes from file (default False) :param str tag: text to associate with key (default None) :param bool retry: retry if database timeout occurs (default True) :return: True if item was added versionr)make_keyget_backend_timeoutraddrkeyvaluerr.readtagretrys rr2zDjangoCache.addBsM8mmCm11**7*;;{sE7D#uEEErcn|||}|j||||||S)aFetch a given key from the cache. If the key does not exist, return default, which itself defaults to None. :param key: key for item :param default: return value if key is missing (default None) :param int version: key version number (default None, cache parameter) :param bool read: if True, return file handle to value (default False) :param float expire_time: if True, return expire_time in tuple (default False) :param tag: if True, return tag in tuple (default False) :param bool retry: retry if database timeout occurs (default False) :return: value for item if key is found else default r-)r0rr)rr4defaultr.r6 expire_timer7r8s rrzDjangoCache.getbs74mmCm11{sGT;UKKKrcd|||}|j|S)aReturn file handle corresponding to `key` from Cache. :param key: Python key to retrieve :param int version: key version number (default None, cache parameter) :return: file open for reading in binary mode :raises KeyError: if key is not found r-)r0rr6rr4r.s rr6zDjangoCache.reads/mmCm11{$$$rc|||}||}|j||||||S)aSet a value in the cache. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. :param key: key for item :param value: value for item :param float timeout: seconds until the item expires (default 300 seconds) :param int version: key version number (default None, cache parameter) :param bool read: read value as bytes from file (default False) :param str tag: text to associate with key (default None) :param bool retry: retry if database timeout occurs (default True) :return: True if item was set r-r/)r0r1rsetr3s rr?zDjangoCache.setsM2mmCm11**7*;;{sE7D#uEEErc|||}||}|j|||S)aTouch a key in the cache. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. :param key: key for item :param float timeout: seconds until the item expires (default 300 seconds) :param int version: key version number (default None, cache parameter) :param bool retry: retry if database timeout occurs (default True) :return: True if key was touched r-r/)r0r1rtouch)rr4rr.r8s rrAzDjangoCache.touchsImmCm11**7*;;{  gu555rcl|||}|j|||||S)aRemove corresponding item for `key` from cache and return value. If `key` is missing, return `default`. Operation is atomic. Concurrent operations will be serialized. :param key: key for item :param default: return value if key is missing (default None) :param int version: key version number (default None, cache parameter) :param float expire_time: if True, return expire_time in tuple (default False) :param tag: if True, return tag in tuple (default False) :param bool retry: retry if database timeout occurs (default True) :return: value for item if key is found else default r-)r0rpop)rr4r:r.r;r7r8s rrCzDjangoCache.pops52mmCm11{sG[#uEEErcf|||}|j||S)aDelete a key from the cache, failing silently. :param key: key for item :param int version: key version number (default None, cache parameter) :param bool retry: retry if database timeout occurs (default True) :return: True if item was deleted r-)r0rdelete)rr4r.r8s rrEzDjangoCache.deletes1mmCm11{!!#u---rrc|||} |j||||S#t$rt d|zdwxYw)aIncrement value by delta for item with key. If key is missing and default is None then raise KeyError. Else if key is missing and default is not None then use default for value. Operation is atomic. All concurrent increment operations will be counted individually. Assumes value may be stored in a SQLite column. Most builds that target machines with 64-bit pointer widths will support 64-bit signed integers. :param key: key for item :param int delta: amount to increment (default 1) :param int version: key version number (default None, cache parameter) :param int default: value if key is missing (default None) :param bool retry: retry if database timeout occurs (default True) :return: new value for item on success else None :raises ValueError: if key is not found and default is None r-zKey '%s' not foundN)r0rincrKeyError ValueErrorrr4deltar.r:r8s rrGzDjangoCache.incrsp.mmCm11 C;##C?? ? C C C1C788d B Cs 6Ac6||| |||S)aDecrement value by delta for item with key. If key is missing and default is None then raise KeyError. Else if key is missing and default is not None then use default for value. Operation is atomic. All concurrent decrement operations will be counted individually. Unlike Memcached, negative values are supported. Value may be decremented below zero. Assumes value may be stored in a SQLite column. Most builds that target machines with 64-bit pointer widths will support 64-bit signed integers. :param key: key for item :param int delta: amount to decrement (default 1) :param int version: key version number (default None, cache parameter) :param int default: value if key is missing (default None) :param bool retry: retry if database timeout occurs (default True) :return: new value for item on success else None :raises ValueError: if key is not found and default is None )rGrJs rdecrzDjangoCache.decrs 4yyufgw>>>rcB|||}||jvS)zReturns True if the key is in the cache and has not expired. :param key: key for item :param int version: key version number (default None, cache parameter) :return: True if key is found r-)r0rr=s rhas_keyzDjangoCache.has_keys&mmCm11dk!!rc4|jS)zSRemove expired items from cache. :return: count of items removed )rexpirer!s rrQzDjangoCache.expire&s {!!###rc:|j||S)zReturn cache statistics hits and misses. :param bool enable: enable collecting statistics (default True) :param bool reset: reset hits and misses to 0 (default False) :return: (hits, misses) )enablereset)rstats)rrSrTs rrUzDjangoCache.stats.s{  e <<.decorator..wrappers,g+T.decorator..__cache_key__s"4vufEEEr)r rrj) rnrjrqrorrr%rr7rrsr.s ` @@r decoratorz&DjangoCache.memoize..decorators)-IdOO%%D7D 4[[         [ 0 F F F F F F F%2G !Nr)callable TypeError)rr%rr.rsr7rrrts``````` rmemoizezDjangoCache.memoizersi^ D>> 7566 6" " " " " " " " " " " Hr)N)NNFFFF)NNFFT)NT)rNNT)TF) __name__ __module__ __qualname____doc__rpropertyrr#r)r+rr2rr6r?rArCrErGrMrOrQrUrWrYr[r]r_rar1rw __classcell__)rs@rr r s77 I I I I I%%X%'''6666'''   FFFFF  LLLL: % % % %    FFFF:"1$d6666( FFFF8 . . . .CCCC:????8 " " " "$$$===='''%%%&&&"""### +: 4 4 4 4  VVVVVVVVrr N)r{ functoolsrdjango.core.cache.backends.baserr ImportErrorcorerr r fanoutr r rfrrrs33555555???????OOO1000000000wwwww)wwwwws !!