| Home | Trees | Indices | Help |
|
|---|
|
|
filecache.py: In-memory cache for files with automatic update
FileCache is the base class for objects that get data from files and that need to stay in sync with files in case they change. It tracks the file creation/modification times and size and calls the updateValue() method if the file has gotten out of date. If the file has not previously been accessed, calls the newValue() method (which by default is the same as updateValue).
Use the get() method to get the value associated with a file. The getValue() method does not check to see if the file has changed and may also be called if that is the desired effect.
The base implementation of FileCache just stores and returns the file contents as a string. Extensions should implement at a minimum the getValue and updateValue methods.
MD5Cache is an implementation of a FileCache that returns the MD5 digest value for a file's contents, updating it only if the file has changed.
FileCacheDict is a dictionary-like class that keeps FileCache objects for a list of filenames. It is instantiated with the *class* (not an instance) of the objects to be created for each entry. New files are added with the add() method, and values are retrieved by index (cachedict[filename]) or using the .get() method.
$Id: filecache.py 678 2005-07-01 21:19:43Z perry $
R. White, 2000 October 1
|
|||
|
FileCache File cache base class |
|||
|
MD5Cache Cached MD5 digest for file contents |
|||
|
FileCacheDict Dictionary-like set of cached values for a set of files |
|||
Imports: os, stat, sys, md5
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Feb 18 14:41:17 2008 | http://epydoc.sourceforge.net |