mò CµMc@s¿dZdkZdkZdkZdkZdkZdkZdkZeidƒZ dgZ dZ de fd„ƒYZ de fd„ƒYZd e fd „ƒYZde fd „ƒYZdS( sE This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) Basic caching classes and methods ================================= - Cache - The generic caching object interfacing with the others - CacheInRam - providing caching in ram - CacheInDisk - provides caches on disk Memcache is also available via a different module (see gluon.contrib.memcache) When web2py is running on Google App Engine, caching will be provided by the GAE memcache (see gluon.contrib.gae_memcache) Ns web2py.cachetCachei,t CacheAbstractcBsMtZdZdZed„Zed„Zed„Zdd„Z d„Z RS(sà Abstract class for cache implementations. Main function is now to provide referenced api documentation. Use CacheInRam or CacheOnDisk instead which are derived from this class. tweb2py_cache_statisticscCs t‚dS(sf Paremeters ---------- request: the global request object N(tNotImplementedError(tselftrequest((t5/home/camdpams_www/Products_Activation/gluon/cache.pyt__init__1scCs t‚dS(sB Tries retrieve the value corresponding to `key` from the cache of the object exists and if it did not expire, else it called the function `f` and stores the output in the cache corresponding to `key`. In the case the output of the function is returned. :param key: the key of the object to be store or retrieved :param f: the function, whose output is to be cached :param time_expire: expiration of the cache in microseconds - `time_expire` is used to compare the current time with the time when the requested object was last saved in cache. It does not affect future requests. - Setting `time_expire` to 0 or negative value forces the cache to refresh. If the function `f` is `None` the cache is cleared. N(R(Rtkeytft time_expire((Rt__call__:scCs t‚dS(sQ Clears the cache of all keys that match the provided regular expression. If no regular expression is provided, it clears all entries in cache. Parameters ---------- regex: if provided, only keys matching the regex will be cleared. Otherwise all keys are cleared. N(R(Rtregex((RtclearPs icCs t‚dS(s Increments the cached value for the given key by the amount in value Parameters ---------- key: key for the cached object to be incremeneted value: amount of the increment (defaults to 1, can be negative) N(R(RRtvalue((Rt increment^s cCsQti|ƒ}x;|iƒD]-\}}|it |ƒƒo ||=qqWdS(sX Auxiliary function called by `clear` to search and clear cache entries N( tretcompileR trtstoragetitemsRRtmatchtstr(RRR RRR((Rt_clearks  ( t__name__t __module__t__doc__tcache_stats_nametNoneRtDEFAULT_TIME_EXPIRER R RR(((RR's    t CacheInRamcBsPtZdZeiƒZhZed„Zed„Z e d„Z dd„Z RS(sŸ Ram based caching This is implemented as global (per process, shared by all threads) dictionary. A mutex-lock mechanism avoid conflicts. cCs—|iiƒ||_|o |i}nd}||ijo6htihdd<dd<<|_ |i|RR"((RRÝs4  'cCsÀt|idƒ}ti|tiƒti|iƒ}|djo|i ƒn|i ||ƒti|iƒjo#hdd<dd<|ti s((RZ(R RRY(RZRttmpŸsN(RYRRTR\(RRR RYR\((RR RYRR ys " (RRRRRRR (((RRWs  (RR,RARER/R5tloggingRt getLoggerRJt__all__RtobjectRRR1R(R]R_R/RR,RARRR1RRERJRR5((Rt?s        MYŠ