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

#include "apr_mem_cache.h"

List of all members.

Public Member Functions

 AprMemCache (const StringPiece &servers, int thread_limit, Hasher *hasher, Statistics *statistics, Timer *timer, MessageHandler *handler)
const GoogleString & server_spec () const
virtual void Get (const GoogleString &key, Callback *callback)
 As mentioned above, Get and MultiGet are blocking in this implementation.
virtual void Put (const GoogleString &key, SharedString *value)
virtual void Delete (const GoogleString &key)
virtual void MultiGet (MultiGetRequest *request)
bool Connect ()
bool valid_server_spec () const
bool GetStatus (GoogleString *status_string)
virtual GoogleString Name () const
virtual bool IsBlocking () const
void RecordError ()
virtual bool IsHealthy () const
virtual void ShutDown ()
 Close down the connection to the memcached servers.
virtual bool MustEncodeKeyInValueOnPut () const
virtual void PutWithKeyInValue (const GoogleString &key, SharedString *key_and_value)
void set_timeout_us (int timeout_us)

Static Public Member Functions

static void InitStats (Statistics *statistics)
static GoogleString FormatName ()

Static Public Attributes

static const size_t kValueSizeThreshold = 1 * 1000 * 1000
static const int64 kHealthCheckpointIntervalMs = 30 * Timer::kSecondMs
 Amount of time after a burst of errors to retry memcached operations.
static const int64 kMaxErrorBurst = 4

Detailed Description

Interface to memcached via the apr_memcache2*, as documented in http://apr.apache.org/docs/apr-util/1.4/group___a_p_r___util___m_c.html.

While this class derives from CacheInterface, it is a blocking implementation, suitable for instantiating underneath an AsyncCache.


Constructor & Destructor Documentation

net_instaweb::AprMemCache::AprMemCache ( const StringPiece &  servers,
int  thread_limit,
Hasher *  hasher,
Statistics *  statistics,
Timer *  timer,
MessageHandler *  handler 
)

servers is a comma-separated list of host[:port] where port defaults to 11211, the memcached default.

thread_limit is used to provide apr_memcache2_server_create with a hard maximum number of client connections to open.


Member Function Documentation

Connects to the server, returning whether the connnection was successful or not.

bool net_instaweb::AprMemCache::GetStatus ( GoogleString *  status_string)

Get detailed status in a string, returning false if the server failed to return status.

virtual bool net_instaweb::AprMemCache::IsHealthy ( ) const [virtual]

Determines whether memcached is healthy enough to attempt another operation. Note that even though there may be multiple shards, some of which are healthy and some not, we don't currently track errors on a per-shard basis, so we effectively declare all the memcached instances unhealthy if any of them are.

Records in statistics that a system error occurred, helping it detect when it's unhealthy if they are too frequent.

Sets the I/O timeout in microseconds. This should be called at setup time and not while there are operations in flight.


Member Data Documentation

Maximum number of errors tolerated within kHealthCheckpointIntervalMs, after which AprMemCache will declare itself unhealthy for kHealthCheckpointIntervalMs.

const size_t net_instaweb::AprMemCache::kValueSizeThreshold = 1 * 1000 * 1000 [static]

Experimentally it seems large values larger than 1M bytes result in a failure, e.g. from load-tests: [Fri Jul 20 10:29:34 2012] [error] [mod_pagespeed 0.10.0.0-1699 @1522] AprMemCache::Put error: Internal error on key http://example.com/image.jpg, value-size 1393146 External to this class, we use a fallback cache (in Apache a FileCache) to handle too-large requests. This is managed by class FallbackCache in ../util.


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