web::webcache Class Reference
[Web client/server base classes]

#include <webcache.hh>

List of all members.

Public Types

typedef std::map< std::string,
cachepage, urlcompare
cachelist
 Cache list.

Public Member Functions

 webcache (int maxsize=1024 *1024, bool autocleanup=false)
virtual ~webcache ()
 Destructor.
bool add (const char *url, const cachepage &page)
bool lookup (const char *url, cachepage &page)
void cleanup (const Time &now)
bool enableAutoCleanup ()
void setMax (int size)
int getMax () const
int size () const
bool reduceCache (int size)

Protected Attributes

thread::recursivemutex fMux
 Mutex.
int fMaxSize
 Maximum cache size (kbytes).
cachelist fCache
 Cache list.
pthread_t fCleanupID
 Thread ID for cleanup task.

Classes

class  cachepage
 Cache page. More...
struct  urlcompare
 URL compare. More...


Detailed Description

Web cache class brief Web cache
Author:
Written January 2005 by Daniel Sigg
Version:
1.0

Constructor & Destructor Documentation

web::webcache::webcache ( int  maxsize = 1024 *1024,
bool  autocleanup = false 
)

Default constructor. brief Default constructor

Parameters:
maxsize Maximum size of cache in bytes
autocleanup Enable auto cleanup


Member Function Documentation

bool web::webcache::add ( const char *  url,
const cachepage page 
)

Add a cache page. brief Add a cache page

Parameters:
url Web address
page Web cache page
Returns:
true if successful

bool web::webcache::lookup ( const char *  url,
cachepage page 
)

Lookup cache page. brief Lookup cache page

Parameters:
url Web address
page Web cache page (return)
Returns:
true if successful

void web::webcache::cleanup ( const Time &  now  ) 

Cleanup cache. Remove expired entries brief Cleanup cache

Parameters:
now Time now

bool web::webcache::enableAutoCleanup (  ) 

Ask for automatic cleanup. Remove expired entries brief Ask for automatic cleanup

Returns:
true if successful

void web::webcache::setMax ( int  size  ) 

Set maximum size of cache. If the requested size is zero, caching is disabled. if the requested size is negative, no limit is applied. brief Set maximum size of cache

Parameters:
size Maximum size

int web::webcache::getMax (  )  const [inline]

Get maximum size of cache (bytes) brief Get maximum size of cache

Returns:
maximum size of cache

int web::webcache::size (  )  const

Get size of cache brief Get size of cache

Returns:
size of cache

bool web::webcache::reduceCache ( int  size  ) 

Reduce cache to desired size. Remove expired entries brief Reduce cache to desired size

Parameters:
size Desired size
Returns:
true if successful


The documentation for this class was generated from the following file:
Generated on Sun Mar 8 19:21:37 2009 for dmt by  doxygen 1.5.4