Package cherrypy :: Package lib :: Module caching :: Class MemoryCache
[hide private]
[frames] | no frames]

Class MemoryCache

source code

object --+    
         |    
     Cache --+
             |
            MemoryCache

An in-memory cache for varying response content.

Each key in self.store is a URI, and each value is an AntiStampedeCache. The response for any given URI may vary based on the values of "selecting request headers"; that is, those named in the Vary response header. We assume the list of header names to be constant for each URI throughout the lifetime of the application, and store that list in ``self.store[uri].selecting_headers``.

The items contained in ``self.store[uri]`` have keys which are tuples of request header values (in the same order as the names in its selecting_headers), and values which are the actual responses.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
clear(self)
Reset the cache to its initial, empty state.
source code
 
expire_cache(self)
Continuously examine cached objects, expiring stale ones.
source code
 
get(self)
Return the current variant if in the cache, else None.
source code
 
put(self, variant, size)
Store the current variant in the cache.
source code
 
delete(self)
Remove ALL cached variants of the current resource.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  maxobjects = 1000
The maximum number of cached objects; defaults to 1000.
  maxobj_size = 100000
The maximum size of each cached object in bytes; defaults to 100 KB.
  maxsize = 10000000
The maximum size of the entire cache in bytes; defaults to 10 MB.
  delay = 600
Seconds until the cached content expires; defaults to 600 (10 minutes).
  antistampede_timeout = 5
Seconds to wait for other threads to release a cache lock.
  expire_freq = 0.1
Seconds to sleep between cache expiration sweeps.
  debug = False
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

clear(self)

source code 

Reset the cache to its initial, empty state.

Overrides: Cache.clear

expire_cache(self)

source code 

Continuously examine cached objects, expiring stale ones.

This function is designed to be run in its own daemon thread, referenced at ``self.expiration_thread``.

get(self)

source code 

Return the current variant if in the cache, else None.

Overrides: Cache.get

put(self, variant, size)

source code 

Store the current variant in the cache.

Overrides: Cache.put

delete(self)

source code 

Remove ALL cached variants of the current resource.

Overrides: Cache.delete