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

#include "system_caches.h"

List of all members.

Classes

struct  MemcachedInterfaces
struct  MetadataShmCacheInfo

Public Types

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

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 (const GoogleString &name, int64 size_kb, GoogleString *error_msg)
NamedLockManager * GetLockManager (SystemRewriteOptions *config)
void PrintCacheStats (StatFlags flags, GoogleString *out)
 Print out stats appropriate for the given flags combination.
void set_thread_limit (int thread_limit)

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 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 ( const GoogleString &  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.

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

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.

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines