Page Speed Optimization Libraries  1.5.27.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes
net_instaweb::PropertyCache Class Reference

Adds property-semantics to a raw cache API. More...

#include "property_cache.h"

List of all members.

Classes

class  Cohort

Public Types

typedef std::vector< const
Cohort * > 
CohortVector

Public Member Functions

 PropertyCache (const GoogleString &cache_key_prefix, CacheInterface *cache, Timer *timer, Statistics *stats, ThreadSystem *threads)
 Does not take ownership of the cache, timer, stats, or threads objects.
void Read (PropertyPage *property_page) const
void ReadWithCohorts (const CohortVector &cohort_list, PropertyPage *property_page) const
const CohortVector GetAllCohorts () const
 Returns all the cohorts from cache.
bool IsStable (const PropertyValue *property) const
 Determines whether a value that was read is reasonably stable.
bool IsExpired (const PropertyValue *property_value, int64 ttl_ms) const
void set_mutations_per_1000_writes_threshold (int x)
const CohortAddCohort (const StringPiece &cohort_name)
const CohortAddCohortWithCache (const StringPiece &cohort_name, CacheInterface *cache)
const CohortGetCohort (const StringPiece &cohort_name) const
void set_enabled (bool x)
bool enabled () const
 Indicates if the property cache is enabled.
GoogleString CacheKey (const StringPiece &key, const Cohort *cohort) const
const CacheInterfacecache_backend () const
Timertimer () const
 Returns timer pointer.
ThreadSystemthread_system () const

Static Public Member Functions

static void InitCohortStats (const GoogleString &cohort, Statistics *statistics)
 Initialize stats for the specified cohort.

Static Public Attributes

static const char kPagePropertyCacheKeyPrefix []
 Property cache key prefixes.
static const char kClientPropertyCacheKeyPrefix []
static const char kDevicePropertyCacheKeyPrefix []

Detailed Description

Adds property-semantics to a raw cache API.


Member Function Documentation

const Cohort* net_instaweb::PropertyCache::AddCohort ( const StringPiece &  cohort_name)

Establishes a new Cohort for this property cache backed by the CacheInteface passed to the constructor. Note that you must call InitCohortStats prior to calling AddCohort.

const Cohort* net_instaweb::PropertyCache::AddCohortWithCache ( const StringPiece &  cohort_name,
CacheInterface cache 
)

Establishes a new Cohort to be backed by the specified CacheInterface. NOTE: Does not take ownership of the CacheInterface object.

GoogleString net_instaweb::PropertyCache::CacheKey ( const StringPiece &  key,
const Cohort cohort 
) const

Gets the underlying key associated with cache_key and a Cohort. This is the key used for the CacheInterface provided to the constructor. This is made visible for testing, to make it possible to inject delays into the cache via DelayCache::DelayKey.

const Cohort* net_instaweb::PropertyCache::GetCohort ( const StringPiece &  cohort_name) const

Returns the specified Cohort* or NULL if not found. Cohorts must be established at startup time, via AddCohort before any pages are processed via Read & Write.

bool net_instaweb::PropertyCache::IsExpired ( const PropertyValue property_value,
int64  ttl_ms 
) const

Determines whether a value is expired relative to the specified TTL.

It is an error (DCHECK) to call this method when !property->has_value().

Note; we could also store the TTL in the cache-value itself. That would be useful if we derived the TTL from the data or other transients. But our envisioned usage has the TTL coming from a configuration that is available at read-time, so for now we just use that.

void net_instaweb::PropertyCache::Read ( PropertyPage property_page) const

Reads all the PropertyValues in all the known Cohorts from cache, calling PropertyPage::Done when done. It is essential that the Cohorts are established prior to calling this function.

void net_instaweb::PropertyCache::ReadWithCohorts ( const CohortVector &  cohort_list,
PropertyPage property_page 
) const

Reads all the PropertyValues in the specified Cohorts from cache, calling PropertyPage::Done when done.

void net_instaweb::PropertyCache::set_enabled ( bool  x) [inline]

Allows turning off all reads/writes with a switch. Writes to a disabled cache are ignored. Reads cause Done(false) to be called immediately.


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