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 | Static Public Attributes | List of all members
net_instaweb::SystemCaches Class Reference

#include "system_caches.h"

Public Types

enum  StatFlags { kDefaultStatFlags = 0, kGlobalView = 1, kIncludeMemcached = 2, kIncludeRedis = 4 }
 

Public Member Functions

 SystemCaches (RewriteDriverFactory *factory, AbstractSharedMem *shm_runtime, int thread_limit)
 
 ~SystemCaches ()
 Note that you must call ShutDown() before this is deleted.
 
bool is_root_process () const
 
void RegisterConfig (SystemRewriteOptions *config)
 
void RootInit ()
 
void ChildInit ()
 
void StopCacheActivity ()
 
void ShutDown (MessageHandler *message_handler)
 
void SetupCaches (ServerContext *server_context, bool enable_property_cache)
 Configures server_context's caches based on its configuration.
 
bool CreateShmMetadataCache (StringPiece name, int64 size_kb, GoogleString *error_msg)
 
NamedLockManagerGetLockManager (SystemRewriteOptions *config)
 
void PrintCacheStats (StatFlags flags, GoogleString *out)
 Print out stats appropriate for the given flags combination.
 
void set_thread_limit (int thread_limit)
 
SystemCachePathGetCache (SystemRewriteOptions *config)
 

Static Public Member Functions

static void InitStats (Statistics *statistics)
 Registers all statistics the cache backends may use.
 

Static Public Attributes

static const char kMemcachedAsync []
 CacheStats prefixes.
 
static const char kMemcachedBlocking []
 
static const char kRedisAsync []
 
static const char kRedisBlocking []
 
static const char kShmCache []
 
static const char kDefaultSharedMemoryPath []
 

Detailed Description

Helps manage setup of cache backends provided by the PSOL library (LRU, File, Memcached, and shared memory metadata), as well as named lock managers. The expectation is that the RewriteDriverFactory for the server will invoke this class's methods in appropriate spots.

It is also expected that the RootInit() method will be called during server setup before the server launches any additional processes, and ChildInit() will be called on any child process handling requests. If the server is single-process, both methods should be called.

Keep in mind, however, that when fork() is involved a process may effectively see both calls, in which case the 'ChildInit' call would come second and override the previous root status.

Constructor & Destructor Documentation

net_instaweb::SystemCaches::SystemCaches ( RewriteDriverFactory factory,
AbstractSharedMem shm_runtime,
int  thread_limit 
)

thread_limit is an estimate of number of threads that may access the cache at the same time. Does not take ownership of shm_runtime.

Member Function Documentation

bool net_instaweb::SystemCaches::CreateShmMetadataCache ( StringPiece  name,
int64  size_kb,
GoogleString error_msg 
)

Creates & registers a shared memory metadata cache segment with given name and size.

Returns whether successful or not, and if not, *error_msg will contain an error message. Meant to be called from config parsing.

SystemCachePath* net_instaweb::SystemCaches::GetCache ( SystemRewriteOptions config)

Finds a Cache for the file_cache_path in the config. If none exists, creates one, using all the other parameters in the SystemRewriteOptions. If multiple calls are made to get a file-cache with the same path, but with different cleaning parameters, the parameters are merged based on these rules:

  1. An explicitly configured option is selected over a default without warning.
  2. When there are two explicit settings, the higher size is picked, but the lower time-interval is picked. A warning is issued to the server log, as this situation should be resolved by the server administrator.
NamedLockManager* net_instaweb::SystemCaches::GetLockManager ( SystemRewriteOptions config)

Returns, perhaps creating it, an appropriate named manager for this config (potentially sharing with others as appropriate).

void net_instaweb::SystemCaches::RegisterConfig ( SystemRewriteOptions config)

Note: RegisterConfig must be called for all relevant configurations before calling RootInit()

void net_instaweb::SystemCaches::set_thread_limit ( int  thread_limit)
inline

For cases where the thread limit isn't known at construction time, call set_thread_limit() before calling any other methods.

void net_instaweb::SystemCaches::ShutDown ( MessageHandler message_handler)

Actually stops some of the work threads, and queues up deferred deletion of various objects on the RewriteDriverFactory.

void net_instaweb::SystemCaches::StopCacheActivity ( )

Tries to block all asynchronous cache activity, causing lookups to fail, to help quicker shutdown. Not 100% guaranteed to work, as not all backends implement it.


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