Package flumotion :: Package component :: Package misc :: Package httpserver :: Module cachemanager :: Class CacheManager
[hide private]

Class CacheManager

source code

                 object --+
                          |
extern.log.log.Loggable --+
                          |
                         CacheManager

Instance Methods [hide private]
 
__init__(self, stats, cacheDir=None, cacheSize=None, cleanupEnabled=None, cleanupHighWatermark=None, cleanupLowWatermark=None, cacheRealm=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
setUp(self)
Initialize the cache manager
source code
 
getIdentifier(self, path)
The returned identifier is a digest of the path encoded in hex string.
source code
 
getCachePath(self, path)
Returns: the cached file path for a path.
source code
 
getTempPath(self, path)
Returns: a temporary file path for a path.
source code
 
updateCacheUsageStatistics(self) source code
 
_updateCacheUsage(self, usage) source code
 
updateCacheUsage(self)
Returns: a defered with the cache usage in bytes.
source code
 
_rmfiles(self, files) source code
 
_setCacheUsage(self, _, usage) source code
 
_cleanUp(self) source code
 
_allocateCacheSpaceAfterCleanUp(self, usage, size) source code
 
_allocateCacheSpace(self, usage, size) source code
defer to tuple
allocateCacheSpace(self, size)
Try to reserve cache space.
source code
 
releaseCacheSpace(self, tag)
Low-level function to release reserved cache space.
source code
 
openCacheFile(self, path)
Returns: a defer to a CacheFile instance or None
source code
 
_newTempFile(self, tag, path, size, mtime=None) source code
 
newTempFile(self, path, size, mtime=None)
Returns: a defer to a TempFile instance or None
source code

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

Inherited from extern.log.log.Loggable: __providedBy__, __provides__, debug, doLog, error, info, log, logFunction, logObjectName, warning, warningFailure, writeMarker

Class Variables [hide private]
  logCategory = 'cache-manager'
Implementors can provide a category to log their messages under.

Inherited from extern.log.log.Loggable: __implemented__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, stats, cacheDir=None, cacheSize=None, cleanupEnabled=None, cleanupHighWatermark=None, cleanupLowWatermark=None, cacheRealm=None)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

setUp(self)

source code 

Initialize the cache manager

@return a defer

getIdentifier(self, path)

source code 

The returned identifier is a digest of the path encoded in hex string. The hash function used is SHA1. It caches the identifiers in a dictionary indexed by path and with a maximum number of entry specified by the constant ID_CACHE_MAX_SIZE.

Returns:
an identifier for path.

getCachePath(self, path)

source code 
Returns:
the cached file path for a path.

getTempPath(self, path)

source code 
Returns:
a temporary file path for a path.

Don't use this function, it's provided for compatibility. Use newTempFile() instead.

updateCacheUsage(self)

source code 
Returns:
a defered with the cache usage in bytes.

allocateCacheSpace(self, size)

source code 

Try to reserve cache space.

If there is not enough space and the cache cleanup is enabled, it will delete files from the cache starting with the ones with oldest access time until the cache usage drops below the fraction specified by the property cleanup-low-threshold.

Returns a 'tag' that should be used to 'free' the cache space using releaseCacheSpace. This tag is needed to better estimate the cache usage, if the cache usage has been updated since cache space has been allocated, freeing up the space should not change the cache usage estimation.

Parameters:
  • size (int) - size to reserve, in bytes
Returns: defer to tuple
an allocation tag or None if the allocation failed.

openCacheFile(self, path)

source code 
Returns:
a defer to a CacheFile instance or None

newTempFile(self, path, size, mtime=None)

source code 
Returns:
a defer to a TempFile instance or None