Page Speed Optimization Libraries
1.13.35.1
|
#include "in_memory_cache.h"
Public Member Functions | |
void | Get (const GoogleString &key, Callback *callback) override |
CacheInterface implementation. | |
void | Put (const GoogleString &key, const SharedString &new_value) override |
void | Delete (const GoogleString &key) override |
GoogleString | Name () const override |
bool | IsBlocking () const override |
bool | IsHealthy () const override |
void | ShutDown () override |
Public Member Functions inherited from net_instaweb::CacheInterface | |
virtual void | MultiGet (MultiGetRequest *request) |
void | PutSwappingString (const GoogleString &key, GoogleString *value) |
virtual CacheInterface * | Backend () |
virtual bool | MustEncodeKeyInValueOnPut () const |
virtual void | PutWithKeyInValue (const GoogleString &key, const SharedString &key_and_value) |
Additional Inherited Members | |
Public Types inherited from net_instaweb::CacheInterface | |
enum | KeyState { kAvailable = 0, kNotFound = 1, kOverload = 2, kNetworkError = 3, kTimeout = 4 } |
typedef std::vector< KeyCallback > | MultiGetRequest |
Static Public Member Functions inherited from net_instaweb::CacheInterface | |
static const char * | KeyStateName (KeyState state) |
Protected Member Functions inherited from net_instaweb::CacheInterface | |
void | ValidateAndReportResult (const GoogleString &key, KeyState state, Callback *callback) |
Invokes callback->ValidateCandidate() and callback->Done() as appropriate. | |
void | ReportMultiGetNotFound (MultiGetRequest *request) |
Simple in-memory implementation of CacheInterface without automatic purging. This implementation is thread-compatible, and must be combined with a mutex to make it thread-safe. It also copies all stored keys and values so it's safe to change SharedStrings after putting them into the cache (e.g. with WriteAt).
The purpose of this implementation is to be fake implementation in tests and debugging.
|
inlineoverridevirtual |
Returns true if this cache is guaranteed to call its callbacks before returning from Get and MultiGet.
Implements net_instaweb::CacheInterface.
|
inlineoverridevirtual |
IsHealthy() is a rough estimation of whether cache is available for any operations. If it's false, caller may reasonably expect that making calls right now is useless as they will fail or have high latency. If it's true, operations should succeed, but some still may fail occasionally. The primary goal is to avoid sending commands to 'unhealthy' caches, e.g. if cache is under heavy load, we do not want to send even more requests.
Memory and file-based caches can simply return 'true'. It should be safe to call this frequently – the implementation shouldn't do much more that check a bool flag under mutex.
Implements net_instaweb::CacheInterface.
|
inlineoverridevirtual |
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 third_party/pagespeed/system/system_caches_test.cc.
Implements net_instaweb::CacheInterface.
|
overridevirtual |
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.
|
inlineoverridevirtual |
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.