Page Speed Optimization Libraries  1.4.26.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions
net_instaweb::FallbackCache Class Reference

#include "fallback_cache.h"

Inheritance diagram for net_instaweb::FallbackCache:
net_instaweb::CacheInterface

List of all members.

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 ()

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines