Page Speed Optimization Libraries
1.5.27.2
|
Composes two caches to form a write-through cache. More...
#include "write_through_cache.h"
Public Member Functions | |
WriteThroughCache (CacheInterface *cache1, CacheInterface *cache2) | |
Does not take ownership of caches passed in. | |
virtual void | Get (const GoogleString &key, Callback *callback) |
virtual void | Put (const GoogleString &key, SharedString *value) |
virtual void | Delete (const GoogleString &key) |
void | set_cache1_limit (size_t limit) |
size_t | cache1_limit () const |
CacheInterface * | cache1 () |
CacheInterface * | cache2 () |
virtual bool | IsBlocking () const |
virtual bool | IsHealthy () const |
virtual void | ShutDown () |
virtual GoogleString | Name () const |
Static Public Member Functions | |
static GoogleString | FormatName (StringPiece l1, StringPiece l2) |
Static Public Attributes | |
static const size_t | kUnlimited |
Friends | |
class | WriteThroughCallback |
Composes two caches to form a write-through cache.
virtual void net_instaweb::WriteThroughCache::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 bool net_instaweb::WriteThroughCache::IsBlocking | ( | ) | const [inline, virtual] |
Returns true if this cache is guaranteed to call its callbacks before returning from Get and MultiGet.
We can fulfill our guarantee only if both caches block.
Implements net_instaweb::CacheInterface.
virtual bool net_instaweb::WriteThroughCache::IsHealthy | ( | ) | const [inline, virtual] |
Returns true if the cache is in a healthy state. Memory and file-based caches can simply return 'true'. But for server-based caches, it is handy to be able to query to see whether it is in a good state. It should be safe to call this frequently -- the implementation shouldn't do much more than check a bool flag under mutex.
Implements net_instaweb::CacheInterface.
virtual GoogleString net_instaweb::WriteThroughCache::Name | ( | ) | const [inline, virtual] |
The name of this CacheInterface -- used for logging and debugging.
It is strongly recommended that you provide a static GoogleString FormatName(...) method for use in formatting the Name() return, and in testing, e.g. in net/instaweb/system/system_caches_test.cc.
Implements net_instaweb::CacheInterface.
virtual void net_instaweb::WriteThroughCache::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.
void net_instaweb::WriteThroughCache::set_cache1_limit | ( | size_t | limit | ) | [inline] |
By default, all data goes into both cache1 and cache2. But if you only want to put small items in cache1, you can set the size limit. Note that both the key and value will count torward the size.
virtual void net_instaweb::WriteThroughCache::ShutDown | ( | ) | [inline, virtual] |
Stops all cache activity. Further Put/Delete calls will be dropped, and MultiGet/Get will call the callback with kNotFound immediately. Note there is no Enable(); once the cache is stopped it is stopped forever. This function is intended for use during process shutdown.
Implements net_instaweb::CacheInterface.