jigdo API

CacheFile Class Reference

Cache with MD5 sums of file contents. More...

#include <cachefile.hh>

List of all members.


Public Member Functions

 CacheFile (const char *dbName)
 Create new database or open existing database.
 ~CacheFile ()
Status find (const byte *&resultData, size_t &resultSize, const string &fileName, uint64 fileSize, time_t mtime)
 Look for an entry in the database which matches the specified filename (which must be absolute), file modification time and file size.
Status findName (const byte *&resultData, size_t &resultSize, const string &fileName, off_t &resultFileSize, time_t &resultMtime)
 Look for an entry in the database which matches the specified filename (which must be absolute).
void insert (const byte *inData, size_t inSize, const string &fileName, time_t mtime, uint64 fileSize)
 Insert/overwrite entry for the given file (name must be absolute, file must have the supplied mtime and size).
template<class Functor>
void insert (Functor f, size_t inSize, const string &fileName, time_t mtime, uint64 fileSize)
 As above, but data is created by the supplied functor object, which must have the method 'void operator()(byte* x)' defined, which when called must write inSize bytes to the memory at x.
void expire (time_t t)
 Remove all entries from the database that have a "last access" time that is older than the given time.

Detailed Description

Cache with MD5 sums of file contents.

Constructor & Destructor Documentation

CacheFile::CacheFile ( const char *  dbName  ) 

Create new database or open existing database.

References compat_dbOpen(), data, and debug.

CacheFile::~CacheFile (  )  [inline]

References Paranoid.


Member Function Documentation

Status CacheFile::find ( const byte *&  resultData,
size_t &  resultSize,
const string &  fileName,
uint64  fileSize,
time_t  mtime 
)

Look for an entry in the database which matches the specified filename (which must be absolute), file modification time and file size.

If no entry is found, return FAILED. Otherwise, return OK and overwrite resultData/resultSize with ptr/len of the binary string associated with this file. The first byte of resultData is the first byte of the "blockLength" entry (see start of this file). The result pointer is only valid until the next database operation.

References FAILED, now, OK, Paranoid, serialize4(), unserialize4(), and unserialize6().

Status CacheFile::findName ( const byte *&  resultData,
size_t &  resultSize,
const string &  fileName,
off_t &  resultFileSize,
time_t &  resultMtime 
)

Look for an entry in the database which matches the specified filename (which must be absolute).

If no entry is found, return FAILED. Otherwise, return OK and overwrite resultData/resultSize with ptr/len of the binary string associated with this file. The first byte of resultData is the first byte of the "blockLength" entry (see start of this file). The result pointer is only valid until the next database operation.

References FAILED, now, OK, Paranoid, serialize4(), unserialize4(), and unserialize6().

Referenced by JigdoCache::readFilenames().

void CacheFile::insert ( const byte *  inData,
size_t  inSize,
const string &  fileName,
time_t  mtime,
uint64  fileSize 
) [inline]

Insert/overwrite entry for the given file (name must be absolute, file must have the supplied mtime and size).

The data for the entry is supplied in inData.

References memcpy.

Referenced by JigdoCache::~JigdoCache().

template<class Functor>
void CacheFile::insert ( Functor  f,
size_t  inSize,
const string &  fileName,
time_t  mtime,
uint64  fileSize 
) [inline]

As above, but data is created by the supplied functor object, which must have the method 'void operator()(byte* x)' defined, which when called must write inSize bytes to the memory at x.

void CacheFile::expire ( time_t  t  ) 

Remove all entries from the database that have a "last access" time that is older than the given time.

References debug, and unserialize4().

Referenced by JigdoCache::~JigdoCache().


The documentation for this class was generated from the following files:

Generated on Tue Sep 23 14:27:42 2008 for jigdo by  doxygen 1.5.6