Page Speed Optimization Libraries
1.2.24.1
|
#include "fallback_cache.h"
Public Member Functions | |
FallbackCache (CacheInterface *small_object_cache, CacheInterface *large_object_cache, int threshold_bytes, MessageHandler *handler) | |
virtual void | Get (const GoogleString &key, Callback *callback) |
virtual void | Put (const GoogleString &key, SharedString *value) |
virtual void | Delete (const GoogleString &key) |
virtual void | MultiGet (MultiGetRequest *request) |
virtual const char * | Name () const |
The name of this CacheInterface -- used for logging and debugging. | |
virtual bool | IsBlocking () const |
virtual bool | IsHealthy () const |
virtual void | ShutDown () |
Provides a mechanism to handle small objects with one cache, and large objects with another cache. This is not a write-through cache; the objects stored in small_object_cache are not stored in large_object_cache, though objects stored in large_object_cache require a flag in small_object_cache that guides Get to look in the large one.
net_instaweb::FallbackCache::FallbackCache | ( | CacheInterface * | small_object_cache, |
CacheInterface * | large_object_cache, | ||
int | threshold_bytes, | ||
MessageHandler * | handler | ||
) |
FallbackCache does not take ownership of either cache that's passed in.
The threshold is compared against the key-size + value-size on put.
virtual void net_instaweb::FallbackCache::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::FallbackCache::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::FallbackCache::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 void net_instaweb::FallbackCache::MultiGet | ( | MultiGetRequest * | request | ) | [virtual] |
Gets multiple keys, calling multiple callbacks. Default implementation simply loops over all the keys and calls Get.
MultiGetRequest, declared above, is a vector of structs of keys and callbacks.
Ownership of the request is transferred to this function.
Reimplemented from net_instaweb::CacheInterface.
virtual void net_instaweb::FallbackCache::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.
virtual void net_instaweb::FallbackCache::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.