Page Speed Optimization Libraries
1.4.26.1
|
#include "system_caches.h"
Classes | |
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) |
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. | |
Static Public Member Functions | |
static void | InitStats (Statistics *statistics) |
Registers all statistics the cache backends may use. | |
Static Public Attributes | |
static const char | kMemcached [] |
CacheStats prefixes. | |
static const char | kShmCache [] |
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.
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.
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).
void net_instaweb::SystemCaches::RegisterConfig | ( | SystemRewriteOptions * | config | ) |
Note: RegisterConfig must be called for all relevant configurations before calling RootInit()
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.