Cheetah.CacheRegion module¶
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().
-
class
Cheetah.CacheRegion.CacheItem(cacheItemID, cacheStore)¶ Bases:
objectA CacheItem is a container storing:
- cacheID (string)
- refreshTime (timestamp or None) : last time the cache was refreshed
- data (string) : the content of the cache
-
clear()¶
-
getData()¶
-
getExpiryTime()¶
-
getRefreshTime()¶
-
hasExpired()¶
-
renderOutput()¶ Can be overridden to implement edge-caching
-
setData(data)¶
-
setExpiryTime(time)¶
-
class
Cheetah.CacheRegion.CacheRegion(regionID, templateCacheIdPrefix='', cacheStore=None)¶ Bases:
objectA 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).
-
clear()¶ drop all the caches stored in this cache region
-
getCacheItem(cacheItemID)¶ Lazy access to a cacheItem
Try to find a cache in the stored caches. If it doesn’t exist, it’s created.
Returns a CacheItem instance.
-
isNew()¶
-