Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
net_instaweb::PropertyPage Class Referenceabstract

#include "property_cache.h"

Inheritance diagram for net_instaweb::PropertyPage:
net_instaweb::AbstractPropertyPage net_instaweb::MockPropertyPage net_instaweb::ProxyFetchPropertyCallback

Public Types

enum  PageType { kPropertyCachePage, kPropertyCacheFallbackPage, kPropertyCachePerOriginPage }
 The cache type associated with this callback.
 

Public Member Functions

virtual PropertyValueGetProperty (const PropertyCache::Cohort *cohort, const StringPiece &property_name)
 
virtual void UpdateValue (const PropertyCache::Cohort *cohort, const StringPiece &property_name, const StringPiece &value)
 
virtual void WriteCohort (const PropertyCache::Cohort *cohort)
 
CacheInterface::KeyState GetCacheState (const PropertyCache::Cohort *cohort)
 
void SetCacheState (const PropertyCache::Cohort *cohort, CacheInterface::KeyState x)
 
void DeleteProperty (const PropertyCache::Cohort *cohort, const StringPiece &property_name)
 
AbstractLogRecordlog_record ()
 
void Read (const PropertyCache::CohortVector &cohort_list)
 Read the property page from cache.
 
void Abort ()
 Abort the reading of PropertyPage.
 
virtual bool IsCacheValid (int64 write_timestamp_ms) const
 
void AddValueFromProtobuf (const PropertyCache::Cohort *cohort, const PropertyValueProtobuf &proto)
 Populate PropertyCacheValues to the respective cohort in PropertyPage.
 
PageType page_type ()
 Returns the type of the page.
 
bool IsCohortPresent (const PropertyCache::Cohort *cohort)
 Returns true if cohort present in the PropertyPage.
 
void FastFinishLookup ()
 
bool EncodePropertyCacheValues (const PropertyCache::Cohort *cohort, PropertyCacheValues *values)
 

Static Public Member Functions

static StringPiece PageTypeSuffix (PageType type)
 Suffix for property cache keys for given page type.
 

Protected Member Functions

 PropertyPage (PageType page_type, StringPiece url, StringPiece options_signature_hash, StringPiece cache_key_suffix, const RequestContextPtr &request_context, AbstractMutex *mutex, PropertyCache *property_cache)
 
virtual void Done (bool success)=0
 Called as a result of PropertyCache::Read when the data is available.
 

Detailed Description

Holds the property values associated with a single key. See more extensive comment for PropertyPage above.

Constructor & Destructor Documentation

net_instaweb::PropertyPage::PropertyPage ( PageType  page_type,
StringPiece  url,
StringPiece  options_signature_hash,
StringPiece  cache_key_suffix,
const RequestContextPtr request_context,
AbstractMutex mutex,
PropertyCache property_cache 
)
protected

The Page takes ownership of the mutex.

Todo:
TODO(pulkitg): Instead of passing full PropertyCache object, just pass objects which PropertyPage needs.

Member Function Documentation

void net_instaweb::PropertyPage::DeleteProperty ( const PropertyCache::Cohort cohort,
const StringPiece &  property_name 
)
virtual

Deletes a property given the property name.

This function deletes the PropertyValue if it already exists, otherwise it is a no-op function.

It is a programming error to call DeleteProperty on a PropertyPage that has not yet been read.

This function actually does not commit it to cache.

Implements net_instaweb::AbstractPropertyPage.

bool net_instaweb::PropertyPage::EncodePropertyCacheValues ( const PropertyCache::Cohort cohort,
PropertyCacheValues *  values 
)

Generates PropertyCacheValues object from all the properties in the given cohort. Returns false, if cohort does not exists in the PropertyPage or no property is present in the cohort.

void net_instaweb::PropertyPage::FastFinishLookup ( )

Finishes lookup for all the cohorts and call PropertyPage::Done() as fast as possible.

CacheInterface::KeyState net_instaweb::PropertyPage::GetCacheState ( const PropertyCache::Cohort cohort)
virtual

This function returns the cache state for a given cohort.

It is a programming error to call GetCacheState on a PropertyPage that has not yet been read.

Implements net_instaweb::AbstractPropertyPage.

virtual PropertyValue* net_instaweb::PropertyPage::GetProperty ( const PropertyCache::Cohort cohort,
const StringPiece &  property_name 
)
virtual

Gets a property given the property name. The property can then be mutated, prior to the PropertyPage being written back to the cache.

The returned PropertyValue object is owned by the PropertyPage and should not be deleted by the caller.

This function creates the PropertyValue if it didn't already exist, either from a previous call or a cache-read.

It is a programming error to call GetProperty on a PropertyPage that has not yet been read.

Note that all the properties in all the Cohorts on a Page are read via PropertyCache::Read. This allows cache implementations that support batching to do so on the read. However, properties are written back to cache one Cohort at a time, via PropertyCache::WriteCohort.

Implements net_instaweb::AbstractPropertyPage.

virtual bool net_instaweb::PropertyPage::IsCacheValid ( int64  write_timestamp_ms) const
inlinevirtual

Called immediately after the underlying cache lookup is done, from PropertyCache::CacheInterfaceCallback::Done().

Reimplemented in net_instaweb::ProxyFetchPropertyCallback, and net_instaweb::MockPropertyPage.

void net_instaweb::PropertyPage::SetCacheState ( const PropertyCache::Cohort cohort,
CacheInterface::KeyState  x 
)

This function set the cache state for a given cohort. This is used by test code and CacheCallback to populate the state.

virtual void net_instaweb::PropertyPage::UpdateValue ( const PropertyCache::Cohort cohort,
const StringPiece &  property_name,
const StringPiece &  value 
)
virtual

Updates the value of a property, tracking stability & discarding writes when the existing data is more up-to-date.

Implements net_instaweb::AbstractPropertyPage.

virtual void net_instaweb::PropertyPage::WriteCohort ( const PropertyCache::Cohort cohort)
virtual

Updates a Cohort of properties into the cache. It is a programming error (dcheck-fail) to Write a PropertyPage that was not read first. It is fine to Write after a failed Read.

Even if a PropertyValue was not changed since it was read, Write should be called periodically to update stability metrics.

Implements net_instaweb::AbstractPropertyPage.


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