Page Speed Optimization Libraries
1.13.35.1
|
#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) |
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) |
SystemCachePath * | GetCache (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 [] |
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 | ( | 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:
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()
|
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.