Ńň ha-Kc @sždZyddklZWn#ej oddklZnXddkZddkZdefd„ƒYZdefd„ƒYZ defd „ƒYZ dS( sT Cache holder classes for Cheetah: Cache regions are defined using the #cache Cheetah directive. Each cache region can be viewed as a dictionary (keyed by cacheRegionID) handling at least one cache item (the default one). It's possible to add cacheItems in a region by using the `varyBy` #cache directive parameter as in the following example:: #def getArticle this is the article content. #end def #cache varyBy=$getArticleID() $getArticle($getArticleID()) #end cache The code above will generate a CacheRegion and add new cacheItem for each value of $getArticleID(). i˙˙˙˙(tmd5Nt CacheItemcBs_eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z RS( sĘ A CacheItem is a container storing: - cacheID (string) - refreshTime (timestamp or None) : last time the cache was refreshed - data (string) : the content of the cache cCs(||_||_d|_d|_dS(Ni(t _cacheItemIDt _cacheStoretNonet _refreshTimet _expiryTime(tselft cacheItemIDt cacheStore((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyt__init__'s   cCs|iotiƒ|ijS(N(Rttime(R((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyt hasExpired-scCs ||_dS(N(R(RR ((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyt setExpiryTime0scCs|iS(N(R(R((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyt getExpiryTime3scCs/tiƒ|_|ii|i||iƒdS(N(R RRtsetRR(Rtdata((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pytsetData6scCs|iS(N(R(R((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pytgetRefreshTime:scCs$|ipt‚|ii|iƒS(N(RtAssertionErrorRtgetR(R((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pytgetData=scCs|iƒpdS(s+Can be overridden to implement edge-cachingt(R(R((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyt renderOutputAscCs |ii|iƒd|_dS(N(RtdeleteRRR(R((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pytclearEs( t__name__t __module__t__doc__R R R RRRRRR(((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyRs        t_CacheDataStoreWrappercBs/eZd„Zd„Zd„Zdd„ZRS(cCs||_||_dS(N(t _dataStoret _keyPrefix(Rt dataStoret keyPrefix((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyR Js cCs|ii|i|ƒS(N(RRR(Rtkey((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyRNscCs|ii|i|ƒdS(N(RRR(RR"((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyRQsicCs$|ii|i||d|ƒdS(NR (RRR(RR"tvalR ((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyRTs(RRR RRR(((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyRIs   t CacheRegioncBs>eZdZeZddd„Zd„Zd„Zd„Z RS(sŐ A `CacheRegion` stores some `CacheItem` instances. This implementation stores the data in the memory of the current process. If you need a more advanced data store, create a cacheStore class that works with Cheetah's CacheStore protocol and provide it as the cacheStore argument to __init__. For example you could use Cheetah.CacheStore.MemcachedCacheStore, a wrapper around the Python memcached API (http://www.danga.com/memcached). RcCslt|_||_||_|ptiiƒ}n||_t|d|d|dƒ|_ h|_ dS(NR!t:( tTruet_isNewt _regionIDt_templateCacheIdPrefixtCheetaht CacheStoretMemoryCacheStoreRRt_wrappedCacheDataStoret _cacheItems(RtregionIDttemplateCacheIdPrefixR ((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyR ds    cCs|iS(N(R'(R((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pytisNewoscCs?x8|iiƒD]'}|i|}|iƒ|i|=qWdS(s1 drop all the caches stored in this cache region N(R.tkeysR(Rt cacheItemIdt cacheItem((s9/usr/lib64/python2.6/site-packages/Cheetah/CacheRegion.pyRrs   cCshtt|ƒƒiƒ}||ijo5|id|d|iƒ}||i|s  +