Page Speed Optimization Libraries  1.7.30.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Static Public Member Functions
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 (PropertyStore *property_store, Timer *timer, Statistics *stats, ThreadSystem *threads)
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 CohortGetCohort (const StringPiece &cohort_name) const
void set_enabled (bool x)
bool enabled () const
 Indicates if the property cache is enabled.
Timer * timer () const
 Returns timer pointer.
ThreadSystem * thread_system () const
PropertyStoreproperty_store ()

Static Public Member Functions

static void InitCohortStats (const GoogleString &cohort, Statistics *statistics)
 Initialize stats for the specified cohort.
static GoogleString GetStatsPrefix (const GoogleString &cohort_name)
 Creates stats prefix for the given cohort.

Detailed Description

Adds property-semantics to a raw cache API.


Constructor & Destructor Documentation

net_instaweb::PropertyCache::PropertyCache ( PropertyStore property_store,
Timer *  timer,
Statistics *  stats,
ThreadSystem *  threads 
)

Does not take ownership of the property_store, timer, stats, or threads objects.


Member Function Documentation

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

Establishes a new Cohort for this property cache. Note that you must call InitCohortStats prior to calling AddCohort.

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