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

#include "purge_set.h"

Public Types

typedef Lru::Iterator Iterator

Public Member Functions

 PurgeSet ()
 PurgeSet (size_t max_size)
 PurgeSet (const PurgeSet &src)
void set_max_size (size_t x)
 Call this immediately after construction.
PurgeSetoperator= (const PurgeSet &src)
bool UpdateGlobalInvalidationTimestampMs (int64 timestamp_ms)
bool Put (const GoogleString &key, int64 timestamp_ms)
void Merge (const PurgeSet &src)
 Merge two invalidation records.
bool IsValid (const GoogleString &key, int64 timestamp_ms) const
int64 global_invalidation_timestamp_ms () const
bool has_global_invalidation_timestamp_ms () const
Iterator Begin () const
Iterator End () const
int num_elements () const
void Clear ()
void Swap (PurgeSet *that)
bool Equals (const PurgeSet &that) const
bool empty () const
GoogleString ToString () const

Static Public Attributes

static const int64 kClockSkewAllowanceMs = 10 * Timer::kMinuteMs
static const int64 kInitialTimestampMs = -1


class InvalidationTimestampHelper

Detailed Description

Maintains a bounded collection of cache-purge records. These can be used to validate data read from a cache.

The entire cache can be flushed as of a certain point in time by calling UpdateInvalidationTimestampMs.

We bound the cache-purge data to a certain number of bytes. When we exceed that, we discard old invalidation records, and bump up the global invalidation timestamp to cover the evicted purges.

Constructor & Destructor Documentation

net_instaweb::PurgeSet::PurgeSet ( )

The default constructor makes a 1-byte invalidation set. Use set_max_size after construction. The default constructor is needed for CopyOnWrite.

Member Function Documentation

bool net_instaweb::PurgeSet::IsValid ( const GoogleString key,
int64  timestamp_ms 
) const

Validates a key against specific invalidation records for that key, and against the overall invalidation timestamp/

bool net_instaweb::PurgeSet::Put ( const GoogleString key,
int64  timestamp_ms 

Adds a new cache purge record to the set. If we spill over our invalidation limit, we will reset the global cache purge-point based on the evicted node.

Returns false if this request represents an excessive warp back in time.

bool net_instaweb::PurgeSet::UpdateGlobalInvalidationTimestampMs ( int64  timestamp_ms)

Flushes any item in the cache older than timestamp_ms.

Returns false if this request represents an excessive warp back in time.

Member Data Documentation

const int64 net_instaweb::PurgeSet::kClockSkewAllowanceMs = 10 * Timer::kMinuteMs

Used for sanity checking timestamps read from the cache.flush file, allowing for small skew and system clock adjustments. Setting this to 10 minutes means that we can prevent any cache entries from being valid for 10 minutes, disabling whatever functionality is dependent on that.

const int64 net_instaweb::PurgeSet::kInitialTimestampMs = -1

Initial value used for the global timestamp. This means there is no valid timestamp.

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