Page Speed Optimization Libraries
1.13.35.1
|
Compressed cache adapter. More...
#include "compressed_cache.h"
Public Member Functions | |
CompressedCache (CacheInterface *cache, Statistics *stats) | |
Does not takes ownership of cache or stats. | |
virtual void | Get (const GoogleString &key, Callback *callback) |
virtual void | Put (const GoogleString &key, const SharedString &value) |
virtual void | Delete (const GoogleString &key) |
virtual GoogleString | Name () const |
virtual CacheInterface * | Backend () |
virtual bool | IsBlocking () const |
virtual bool | IsHealthy () const |
virtual void | ShutDown () |
int64 | CorruptPayloads () const |
int64 | OriginalSize () const |
int64 | CompressedSize () const |
Public Member Functions inherited from net_instaweb::CacheInterface | |
virtual void | MultiGet (MultiGetRequest *request) |
void | PutSwappingString (const GoogleString &key, GoogleString *value) |
virtual bool | MustEncodeKeyInValueOnPut () const |
virtual void | PutWithKeyInValue (const GoogleString &key, const SharedString &key_and_value) |
Static Public Member Functions | |
static void | InitStats (Statistics *stats) |
static GoogleString | FormatName (StringPiece cache) |
Static Public Member Functions inherited from net_instaweb::CacheInterface | |
static const char * | KeyStateName (KeyState state) |
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 |
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) |
Compressed cache adapter.
|
inlinevirtual |
If this cache is merely a wrapper around a backend that actually does all the work, returns that backend cache object. Otherwise just returns 'this'. Used for testing.
Reimplemented from net_instaweb::CacheInterface.
int64 net_instaweb::CompressedCache::CompressedSize | ( | ) | const |
Total number of compressed bytes inserted since the cache was started.
int64 net_instaweb::CompressedCache::CorruptPayloads | ( | ) | const |
Total number of times we did a fetch from the underlying cache and it failed to uncompress due to corruption.
|
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.
|
inlinevirtual |
Returns true if this cache is guaranteed to call its callbacks before returning from Get and MultiGet.
Implements net_instaweb::CacheInterface.
|
virtual |
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.
|
inlinevirtual |
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.
int64 net_instaweb::CompressedCache::OriginalSize | ( | ) | const |
Total number of uncompressed bytes inserted since the cache was started.
|
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 |
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.