#include "threadsafe_cache.h"
Public Member Functions | |
ThreadsafeCache (CacheInterface *cache, AbstractMutex *mutex) | |
Takes ownership of the cache and mutex that's passed in. | |
virtual void | Get (const GoogleString &key, Callback *callback) |
virtual void | Put (const GoogleString &key, SharedString *value) |
virtual void | Delete (const GoogleString &key) |
virtual const char * | Name () const |
The name of this CacheInterface -- used for logging and debugging. |
Composes a cache with a Mutex to form a threadsafe cache. Note that cache callbacks will be run in a thread that is dependent on the cache implementation. This wrapper class just guarantees the thread safety of the cache itself, not the callbacks.
virtual void net_instaweb::ThreadsafeCache::Get | ( | const GoogleString & | key, | |
Callback * | callback | |||
) | [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.
Implements net_instaweb::CacheInterface.
virtual void net_instaweb::ThreadsafeCache::Put | ( | const GoogleString & | key, | |
SharedString * | value | |||
) | [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.
Implements net_instaweb::CacheInterface.