Abstract interface for a cache. More...
#include "cache_interface.h"
Classes | |
class | Callback |
Public Types | |
enum | KeyState { kAvailable, kNotFound } |
Public Member Functions | |
virtual void | Get (const GoogleString &key, Callback *callback)=0 |
virtual void | Put (const GoogleString &key, SharedString *value)=0 |
virtual void | Delete (const GoogleString &key)=0 |
virtual const char * | Name () const =0 |
The name of this CacheInterface -- used for logging and debugging. | |
Protected Member Functions | |
void | ValidateAndReportResult (const GoogleString &key, KeyState state, Callback *callback) |
Invokes callback->ValidateCandidate() and callback->Done() as appropriate. |
Abstract interface for a cache.
virtual void net_instaweb::CacheInterface::Get | ( | const GoogleString & | key, | |
Callback * | callback | |||
) | [pure virtual] |
Initiates a cache fetch, calling callback->ValidateCandidate() and then callback->Done(state) when done.
Note: implementations should normally invoke the callback via ValidateAndReportResult, which will combine ValidateCandidate() and Done() together properly.
Implemented in net_instaweb::DelayCache, net_instaweb::FileCache, net_instaweb::LRUCache, net_instaweb::MockTimeCache, net_instaweb::ThreadsafeCache, and net_instaweb::WriteThroughCache.
virtual void net_instaweb::CacheInterface::Put | ( | const GoogleString & | key, | |
SharedString * | value | |||
) | [pure virtual] |
Puts a value into the cache. The value that is passed in is not modified, but the SharedString is passed by non-const pointer because its reference count is bumped.
Implemented in net_instaweb::DelayCache, net_instaweb::FileCache, net_instaweb::LRUCache, net_instaweb::MockTimeCache, net_instaweb::ThreadsafeCache, and net_instaweb::WriteThroughCache.