/opt/alt/python37/lib/python3.7/site-packages/beaker
NameSizeModeActions
crypto/-0755rm
ext/-0755rm
__pycache__/-0755rm
cache.py219170644editdlrm
cache.pyc228710644editdlrm
cache.pyo228710644editdlrm
container.py240790644editdlrm
container.pyc299380644editdlrm
container.pyo299380644editdlrm
converters.py8980644editdlrm
converters.pyc11980644editdlrm
converters.pyo11980644editdlrm
cookie.py31890644editdlrm
cookie.pyc22850644editdlrm
cookie.pyo22850644editdlrm
exceptions.py4430644editdlrm
exceptions.pyc17600644editdlrm
exceptions.pyo17600644editdlrm
middleware.py64820644editdlrm
middleware.pyc68190644editdlrm
middleware.pyo68190644editdlrm
session.py328270644editdlrm
session.pyc333150644editdlrm
session.pyo332270644editdlrm
synchronization.py115250644editdlrm
synchronization.pyc139330644editdlrm
synchronization.pyo139330644editdlrm
util.py171180644editdlrm
util.pyc217010644editdlrm
util.pyo216250644editdlrm
_compat.py42560644editdlrm
_compat.pyc61010644editdlrm
_compat.pyo61010644editdlrm
__init__.py230644editdlrm
__init__.pyc1840644editdlrm
__init__.pyo1840644editdlrm
Edit: /opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyo (22871B)
Ñò ø[c@sðdZddkZddklZddklZlZlZlZddk i Z ddk i Z ddk lZddklZlZddklZddkiiZddkiiZddkiiZddkiiZddkiiZddkii Z ddk!l"Z"hZ#hZ$d e%fd „ƒYZ&e&h e i'd 6e i(d 6e i)d 6ei*d6ei+d6ei,d6ei-d6ei.d6e i/d6ƒZ0d„Z1d„Z2de%fd„ƒYZ3de%fd„ƒYZ4d„Z5d„Z6dS(sðThis package contains the "front end" classes and functions for Beaker caching. Included are the :class:`.Cache` and :class:`.CacheManager` classes, as well as the function decorators :func:`.region_decorate`, :func:`.region_invalidate`. iÿÿÿÿN(tchain(tu_t unicode_texttfunc_signaturet bindfuncargs(tsha1(tBeakerExceptiontInvalidCacheBackendError(t _threading(twrapst _backendscBs)eZeZd„Zd„Zd„ZRS(cCs||_tiƒ|_dS(N(t_clsmapRtLockt_mutex(tselftclsmap((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt__init__<s cCsy|i|SWnwtj ok}|ipR|iiƒz0|ip|iƒt|_n|i|SWd|iiƒXn|‚nXdS(N(R tKeyErrort initializedR tacquiret_inittTruetrelease(Rtkeyte((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt __getitem__@s     c CslyRddk}x?|idƒD].}yJ|iƒ}|i}||ijotd|ƒ‚n||i|       (t__name__t __module__tFalseRRRR(((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyR 9s  tmemorytdbmRs ext:memcacheds ext:databasesext:sqlas ext:googles ext:mongodbs ext:rediscGst|dd|ƒS(s Decorate a function such that its return result is cached, using a "region" to indicate the cache arguments. Example:: from beaker.cache import cache_regions, cache_region # configure regions cache_regions.update({ 'short_term':{ 'expire':60, 'type':'memory' } }) @cache_region('short_term', 'load_things') def load(search_term, limit, offset): '''Load from a database given a search term, limit, offset.''' return database.query(search_term)[offset:offset + limit] The decorator can also be used with object methods. The ``self`` argument is not part of the cache key. This is based on the actual string name ``self`` being in the first argument position (new in 1.6):: class MyThing(object): @cache_region('short_term', 'load_things') def load(self, search_term, limit, offset): '''Load from a database given a search term, limit, offset.''' return database.query(search_term)[offset:offset + limit] Classmethods work as well - use ``cls`` as the name of the class argument, and place the decorator around the function underneath ``@classmethod`` (new in 1.6):: class MyThing(object): @classmethod @cache_region('short_term', 'load_things') def load(cls, search_term, limit, offset): '''Load from a database given a search term, limit, offset.''' return database.query(search_term)[offset:offset + limit] :param region: String name of the region corresponding to the desired caching arguments, established in :attr:`.cache_regions`. :param \*args: Optional ``str()``-compatible arguments which will uniquely identify the key used by this decorated function, in addition to the positional arguments passed to the function itself at call time. This is recommended as it is needed to distinguish between any two functions or methods that have the same name (regardless of parent class or not). .. note:: The function being decorated must only be called with positional arguments, and the arguments must support being stringified with ``str()``. The concatenation of the ``str()`` version of each argument, combined with that of the ``*args`` sent to the decorator, forms the unique cache key. .. note:: When a method on a class is decorated, the ``self`` or ``cls`` argument in the first position is not included in the "key" used for caching. New in 1.6. N(t_cache_decoratetNone(tregiontargs((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt cache_region…sDcGs„t|ƒo!|p |i}n|i}n|ptdƒ‚n t|}ti||ƒ}t||idt i ƒ|ƒdS(sB Invalidate a cache region corresponding to a function decorated with :func:`.cache_region`. :param namespace: The namespace of the cache to invalidate. This is typically a reference to the original function (as returned by the :func:`.cache_region` decorator), where the :func:`.cache_region` decorator applies a "memo" to the function in order to locate the string name of the namespace. :param region: String name of the region used with the decorator. This can be ``None`` in the usual case that the decorated function itself is passed, not the string name of the namespace. :param args: Stringifyable arguments that are used to locate the correct key. This consists of the ``*args`` sent to the :func:`.cache_region` decorator itself, plus the ``*args`` sent to the function itself at runtime. Example:: from beaker.cache import cache_regions, cache_region, region_invalidate # configure regions cache_regions.update({ 'short_term':{ 'expire':60, 'type':'memory' } }) @cache_region('short_term', 'load_data') def load(search_term, limit, offset): '''Load from a database given a search term, limit, offset.''' return database.query(search_term)[offset:offset + limit] def invalidate_search(search_term, limit, offset): '''Invalidate the cached storage for a given search term, limit, offset.''' region_invalidate(load, 'short_term', 'load_data', search_term, limit, offset) Note that when a method on a class is decorated, the first argument ``cls`` or ``self`` is not included in the cache key. This means you don't send it to :func:`.region_invalidate`:: class MyThing(object): @cache_region('short_term', 'some_data') def load(self, search_term, limit, offset): '''Load from a database given a search term, limit, offset.''' return database.query(search_term)[offset:offset + limit] def invalidate_search(self, search_term, limit, offset): '''Invalidate the cached storage for a given search term, limit, offset.''' region_invalidate(self.load, 'short_term', 'some_data', search_term, limit, offset) s1Region or callable function namespace is requiredt key_lengthN( tcallablet _arg_regiont_arg_namespaceRt cache_regionstCachet _get_cachet_cache_decorator_invalidatetgettutiltDEFAULT_CACHE_KEY_LENGTH(t namespaceR7R8tcache((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pytregion_invalidateÌs6    R?cBs¶eZdZddddd„Zed„ƒZd„ZeZd„Z e Z d„Z e Z d„Z eidƒd „ƒZd „Zd „Zd „Zd „Zd„Zd„ZRS(sEFront-end to the containment API implementing a data cache. :param namespace: the namespace of this Cache :param type: type of cache to use :param expire: seconds to keep cached data :param expiretime: seconds to keep cached data (legacy support) :param starttime: time when cache was cache was R3cKs¬y(t|}t|tƒo |‚nWn#tj otd|ƒ‚nX|dj ot|ƒ}n||_||||_|p||_ ||_ ||_ dS(NsUnknown cache implementation %r( RR#RRt TypeErrorR6tinttnamespace_nameREt expiretimet starttimetnsargs(RREttypeRKRLtexpireRMtcls((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyR!s    cCsN|t|ƒ}y t|SWn+tj o|||t|<}|SXdS(N(tstrtcache_managersR(RPREtkwRRF((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyR@3s  cKs|i||i|ƒdS(N(t _get_valuet set_value(RRtvalueRS((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pytput<scKs|i||iƒS(s*Retrieve a cached value from the container(RTt get_value(RRRS((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyRB@scKs |i||}|iƒdS(N(RTt clear_value(RRRSt mycontainer((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt remove_valueEscKs€t|tƒo|iddƒ}nd|jo|i||S|id|iƒ|id|iƒti||i |S(NtasciitbackslashreplaceRNRKRL( R#Rtencodet_legacy_get_valuet setdefaultRKRLt containertValueRE(RRRS((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyRTJs sÔSpecifying a 'type' and other namespace configuration with cache.get()/put()/etc. is deprecated. Specify 'type' and other namespace configuration to cache_manager.get_cache() and/or the Cache constructor instead.c Ks|id|iƒ}|iddƒ}|iddƒ}|iiƒ}|i|ƒt|iid||}|i|d|d|d|ƒS(NRKRLt createfuncRN( tpopRKR6RMtcopytupdateR?RERT( RRRNRSRKRLRctkwargstc((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyR_Vs cCs|iiƒdS(s'Clear all the values from the namespaceN(REtremove(R((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pytcleardscCs |i|ƒS(N(RB(RR((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyRiscCs|i|ƒiƒS(N(RTthas_current_value(RR((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt __contains__lscCs ||jS(N((RR((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pythas_keyoscCs|i|ƒdS(N(R[(RR((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt __delitem__rscCs|i||ƒdS(N(RW(RRRV((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt __setitem__usN(R0R1t__doc__R6Rt classmethodR@RWRURBRXR[RiRTRCt deprecatedR_RjRRlRmRnRo(((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyR?s$          t CacheManagercBsGeZd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cKs2||_|idhƒ|_ti|iƒdS(sÛInitialize a CacheManager object with a set of options Options should be parsed with the :func:`~beaker.util.parse_cache_config_options` function to ensure only valid options are used. R>N(RgRdtregionsR>Rf(RRg((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyRzs cKs,|iiƒ}|i|ƒti||ƒS(N(RgReRfR?R@(RR RgRS((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt get_cacheˆs cCsA||ijotd|ƒ‚n|i|}ti||ƒS(NsCache region not configured: %s(RtRR?R@(RR R7RS((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pytget_cache_regions cGs t||ŒS(sHDecorate a function to cache itself using a cache region The region decorator requires arguments if there are more than two of the same named function, in the same module. This is because the namespace used for the functions cache is based on the functions name and the module. Example:: # Assuming a cache object is available like: cache = CacheManager(dict_of_config_options) def populate_things(): @cache.region('short_term', 'some_data') def load(search_term, limit, offset): return load_the_data(search_term, limit, offset) return load('rabbits', 20, 0) .. note:: The function being decorated must only be called with positional arguments. (R9(RR7R8((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyR7“scGst|||ŒS(sÔInvalidate a cache region namespace or decorated function This function only invalidates cache spaces created with the cache_region decorator. :param namespace: Either the namespace of the result to invalidate, or the cached function :param region: The region the function was cached to. If the function was cached to a single region then this argument can be None :param args: Arguments that were used to differentiate the cached function as well as the arguments passed to the decorated function Example:: # Assuming a cache object is available like: cache = CacheManager(dict_of_config_options) def populate_things(invalidate=False): @cache.region('short_term', 'some_data') def load(search_term, limit, offset): return load_the_data(search_term, limit, offset) # If the results should be invalidated first if invalidate: cache.region_invalidate(load, None, 'some_data', 'rabbits', 20, 0) return load('rabbits', 20, 0) (RG(RRER7R8((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyRG²s#cOst|||dƒS(sDecorate a function to cache itself with supplied parameters :param args: Used to make the key unique for this function, as in region() above. :param kwargs: Parameters to be passed to get_cache(), will override defaults Example:: # Assuming a cache object is available like: cache = CacheManager(dict_of_config_options) def populate_things(): @cache.cache('mycache', expire=15) def load(search_term, limit, offset): return load_the_data(search_term, limit, offset) return load('rabbits', 20, 0) .. note:: The function being decorated must only be called with positional arguments. N(R5R6(RR8Rg((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyRF×scOsz|i}|i||}t|dƒo&t|i}|idtiƒ}n|idtiƒ}t |||ƒdS(s4Invalidate a cache decorated function This function only invalidates cache spaces created with the cache decorator. :param func: Decorated function to invalidate :param args: Used to make the key unique for this function, as in region() above. :param kwargs: Parameters that were passed for use by get_cache(), note that this is only required if a ``type`` was specified for the function Example:: # Assuming a cache object is available like: cache = CacheManager(dict_of_config_options) def populate_things(invalidate=False): @cache.cache('mycache', type="file", expire=15) def load(search_term, limit, offset): return load_the_data(search_term, limit, offset) # If the results should be invalidated first if invalidate: cache.invalidate(load, 'mycache', 'rabbits', 20, 0, type="file") return load('rabbits', 20, 0) R<R:N( R=RuthasattrR>R<RBRCRDRdRA(RtfuncR8RgRERFtcacheregR:((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyt invalidateõs!  ( R0R1RRuRvR7RGRFRz(((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyRsys     % cs(dg‰‡‡‡‡‡fd†}|S(s$Return a caching function decorator.c s„tiˆƒ‰tiˆƒ‰tˆƒ‰tˆƒ‡‡‡‡‡‡‡‡‡f d†ƒ}ˆ|_ˆdj o ˆ|_n|S(Nc s+ˆdp¤ˆdj ofˆtjotdˆƒ‚ntˆ}|idtƒpˆˆˆŽStiˆ|ƒˆdRRBRR?R@Rut ExceptionRtitemsRtjointmapRRCRDRdtlenRIRR^t hexdigestR0RX( R8Rgtregtcache_key_kwargst_[1]RRVtcache_key_argst cache_keyRyR:R~( Rxtmanagert deco_argsRFREt skip_selfR7t signaturetoptions(RgR8s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pytcached+s:    R* #(RCtfunc_namespacet has_self_argRR R=R6R<(RxR(RFR‹R7RŠRŽ(RERxRRŒs=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pytdecorate&s 3/   N(R6(R‹RŠRŽR7R’((R‹R7RFRŠRŽs=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyR5!s 8cCsntdƒitt|ƒƒ}t|ƒt|iƒ|jot|idƒƒiƒ}n|i|ƒdS(s3Invalidate a cache key based on function arguments.R}sutf-8N( RRR‚RƒRJRR^R„R[(RFR:R8R‰((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pyRAas (7RpR)t itertoolsRtbeaker._compatRRRRtbeaker.containerRat beaker.utilRCtbeaker.crypto.utilRtbeaker.exceptionsRRtbeaker.synchronizationRtbeaker.ext.memcachedtextt memcachedtbeaker.ext.databasetdatabasetbeaker.ext.sqlatsqlatbeaker.ext.googletgoogletbeaker.ext.mongodbtmongodbtbeaker.ext.redisnmtredisnmt functoolsR R>RRtobjectR tMemoryNamespaceManagertDBMNamespaceManagertFileNamespaceManagertMemcachedNamespaceManagertDatabaseNamespaceManagertSqlaNamespaceManagertGoogleNamespaceManagertMongoNamespaceManagertRedisNamespaceManagerRR9RGR?RsR5RA(((s=/opt/alt/python37/lib/python3.7/site-packages/beaker/cache.pytsD "?         G Gf¨ @