Package horizons :: Package util :: Module yamlcachestorage :: Class YamlCacheStorage
[hide private]
[frames] | no frames]

Class YamlCacheStorage

source code

Store the YamlCache data in a cache.

An instance of this class provides a implements a cache that always has all the data in memory. It tries to also load the data from disk and write it back on disk but if it fails then it just ignores the errors and keeps working.

Instance Methods [hide private]
 
__init__(self, filename) source code
 
_reload(self)
Load the cache from disk if possible.
source code
 
_clear(self)
Clear the cache in memory.
source code
 
sync(self)
Write the file to disk if possible.
source code
 
close(self)
Write the file to disk if possible and then invalidate the object in memory.
source code
 
__getitem__(self, key)
This function enables the following syntax: cache[key]
source code
 
__setitem__(self, key, value)
This function enables the following syntax: cache[key] = value
source code
 
__contains__(self, item)
This function enables the following syntax: item in cache
source code
 
__str__(self) source code
Class Methods [hide private]
 
_validate(cls, data)
Make sure data is a tuple (version no, _data dict) with the right version.
source code
 
open(cls, filename)
Open the cache specified by the file name or create an empty one otherwise.
source code
Class Variables [hide private]
  log = logging.getLogger("yamlcachestorage")
  version = 1
Method Details [hide private]

_reload(self)

source code 

Load the cache from disk if possible. Create an empty cache otherwise.

sync(self)

source code 

Write the file to disk if possible. Do nothing otherwise.