Page Speed Optimization Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
net_instaweb::CacheKeyPrepender Class Reference

#include "cache_key_prepender.h"

Inheritance diagram for net_instaweb::CacheKeyPrepender:

Public Member Functions

 CacheKeyPrepender (StringPiece prefix, CacheInterface *cache)
 Does not takes ownership of the cache.
void Get (const GoogleString &key, Callback *callback) override
 Implementation of CacheInterface.
void MultiGet (MultiGetRequest *request) override
void Put (const GoogleString &key, const SharedString &value) override
void Delete (const GoogleString &key) override
CacheInterfaceBackend () override
bool IsBlocking () const override
bool IsHealthy () const override
 Implementation of CacheInterface.
void ShutDown () override
GoogleString Name () const override
- Public Member Functions inherited from net_instaweb::CacheInterface
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 GoogleString FormatName (StringPiece prefix, 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< KeyCallbackMultiGetRequest
- 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)

Detailed Description

Implements a cache adapter that prepends a fixed string to all keys that are used in the cache. Can be used for isolating unit tests of external caches (e.g. memcached).

Member Function Documentation

CacheInterface* net_instaweb::CacheKeyPrepender::Backend ( )

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.

bool net_instaweb::CacheKeyPrepender::IsBlocking ( ) const

Returns true if this cache is guaranteed to call its callbacks before returning from Get and MultiGet.

Implements net_instaweb::CacheInterface.

void net_instaweb::CacheKeyPrepender::MultiGet ( MultiGetRequest *  request)

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.

GoogleString net_instaweb::CacheKeyPrepender::Name ( ) const

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/

Implements net_instaweb::CacheInterface.

void net_instaweb::CacheKeyPrepender::Put ( const GoogleString key,
const SharedString value 

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::CacheKeyPrepender::ShutDown ( )

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.

The documentation for this class was generated from the following file: