Package Ganga :: Package Utility :: Module Caching :: Class Cache
[hide private]
[frames] | no frames]

Class Cache

source code

object --+
         |
        Cache
Known Subclasses:

An abstract, multi-threaded cache object.

Instance Methods [hide private]
 
__init__(self, dset, max_size=0)
Builds a cache with a limit of max_size entries.
source code
 
__setitem__(self, name, value)
Populates the cache with a given name and value.
source code
 
__getitem__(self, name)
Gets a value from the cache, builds it if required.
source code
 
__delitem__(self, name) source code
 
_get_entry(self, key) source code
 
_checkitem(self, name)
Gets a value from the cache, builds it if required.
source code
 
mru(self)
Returns the Most Recently Used key
source code
 
lru(self)
Returns the Least Recently Used key
source code
 
key(self, name)
Override this method to extract a key from the name passed to the [] operator
source code
 
commit(self)
Override this method if you want to do something each time the underlying dictionary is modified (e.g.
source code
 
clear(self)
Clears the cache
source code
 
check(self, key, name, entry)
Override this method to check whether the entry with the given name is stale.
source code
 
build(self, key, name, opened, entry)
Build the cached value with the given name from the given opened resource.
source code
 
_access(self, entry)
Internal use only, must be invoked within a cache lock.
source code
 
_checklru(self)
Internal use only, must be invoked within a cache lock.
source code
 
_pack(self, entry, value)
Store the value in the entry.
source code
 
_unpack(self, entry)
Recover the value from the entry, returns NOT_INITIALIZED if it is not OK.
source code

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

Class Variables [hide private]
  cacheDict = {}
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, dset, max_size=0)
(Constructor)

source code 

Builds a cache with a limit of max_size entries. If this limit is exceeded, the Least Recently Used entry is discarded. if max_size==0, the cache is unbounded (no LRU rule is applied).

Overrides: object.__init__

_checkitem(self, name)

source code 

Gets a value from the cache, builds it if required. Returns a tuple is_new, key, value, entry. If is_new is True, the result had to be rebuilt.

commit(self)

source code 

Override this method if you want to do something each time the underlying dictionary is modified (e.g. make it persistent).

check(self, key, name, entry)

source code 

Override this method to check whether the entry with the given name is stale. Return None if it is fresh or an opened resource if it is stale. The object returned will be passed to the 'build' method as the 'opened' parameter. Use the 'entry' parameter to store meta-data if required. Don't worry about multiple threads accessing the same name, as this method is properly isolated.

build(self, key, name, opened, entry)

source code 

Build the cached value with the given name from the given opened resource. Use entry to obtain or store meta-data if needed. Don't worry about multiple threads accessing the same name, as this method is properly isolated.

_access(self, entry)

source code 

Internal use only, must be invoked within a cache lock. Updates the access list.

_checklru(self)

source code 

Internal use only, must be invoked within a cache lock. Removes the LRU entry if needed.