18 #ifndef PAGESPEED_SYSTEM_SYSTEM_CACHES_H_
19 #define PAGESPEED_SYSTEM_SYSTEM_CACHES_H_
35 namespace net_instaweb {
37 class AbstractSharedMem;
39 class NamedLockManager;
40 class QueuedWorkerPool;
41 class RewriteDriverFactory;
45 class SystemCachePath;
64 static const char kMemcachedBlocking[];
65 static const char kRedisAsync[];
66 static const char kRedisBlocking[];
67 static const char kShmCache[];
69 static const char kDefaultSharedMemoryPath[];
72 kDefaultStatFlags = 0,
74 kIncludeMemcached = 2,
90 bool is_root_process()
const {
return is_root_process_; }
105 void ShutDown(MessageHandler* message_handler);
108 void SetupCaches(ServerContext* server_context,
bool enable_property_cache);
116 StringPiece name, int64 size_kb,
GoogleString* error_msg);
144 struct MetadataShmCacheInfo {
145 MetadataShmCacheInfo()
146 : cache_to_use(NULL), cache_backend(NULL), initialized(false) {}
149 CacheInterface* cache_to_use;
151 MetadataShmCache* cache_backend;
157 struct ExternalCacheInterfaces {
158 ExternalCacheInterfaces() : async(NULL), blocking(NULL) {}
159 CacheInterface* async;
160 CacheInterface* blocking;
175 ExternalCacheInterfaces ConstructExternalCacheInterfacesFromBlocking(
176 CacheInterface* backend, QueuedWorkerPool* pool,
177 int batcher_max_parallel_lookups,
const char* async_stats_name,
178 const char* blocking_stats_name);
186 ExternalCacheInterfaces NewMemcached(SystemRewriteOptions* config);
187 ExternalCacheInterfaces NewRedis(SystemRewriteOptions* config);
193 ExternalCacheInterfaces NewExternalCache(SystemRewriteOptions* config);
197 MetadataShmCacheInfo* LookupShmMetadataCache(
const GoogleString& name);
203 MetadataShmCacheInfo* GetShmMetadataCacheOrDefault(
204 SystemRewriteOptions* config);
207 void SetupPcacheCohorts(ServerContext* server_context,
208 bool enable_property_cache);
210 scoped_ptr<SlowWorker> slow_worker_;
212 RewriteDriverFactory* factory_;
213 AbstractSharedMem* shared_mem_runtime_;
215 bool is_root_process_;
227 typedef std::map<GoogleString, SystemCachePath*> PathCacheMap;
228 PathCacheMap path_cache_map_;
236 scoped_ptr<QueuedWorkerPool> memcached_pool_;
237 scoped_ptr<QueuedWorkerPool> redis_pool_;
244 std::vector<AprMemCache*> memcache_servers_;
245 std::vector<RedisCache*> redis_servers_;
254 typedef std::map<GoogleString, ExternalCacheInterfaces> ExternalCachesMap;
255 ExternalCachesMap external_caches_map_;
259 typedef std::map<GoogleString, MetadataShmCacheInfo*> MetadataShmCacheMap;
262 MetadataShmCacheMap metadata_shm_caches_;
264 MD5Hasher cache_hasher_;
266 bool default_shm_metadata_cache_creation_failed_;
void ShutDown(MessageHandler *message_handler)
NamedLockManager * GetLockManager(SystemRewriteOptions *config)
static const char kMemcachedAsync[]
CacheStats prefixes.
Definition: system_caches.h:63
void SetupCaches(ServerContext *server_context, bool enable_property_cache)
Configures server_context's caches based on its configuration.
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
~SystemCaches()
Note that you must call ShutDown() before this is deleted.
void PrintCacheStats(StatFlags flags, GoogleString *out)
Print out stats appropriate for the given flags combination.
Definition: system_rewrite_options.h:40
void RegisterConfig(SystemRewriteOptions *config)
bool CreateShmMetadataCache(StringPiece name, int64 size_kb, GoogleString *error_msg)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
SystemCaches(RewriteDriverFactory *factory, AbstractSharedMem *shm_runtime, int thread_limit)
Definition: abstract_shared_mem.h:86
SystemCachePath * GetCache(SystemRewriteOptions *config)
Definition: system_caches.h:60
static void InitStats(Statistics *statistics)
Registers all statistics the cache backends may use.
Abstract interface for a cache.
Definition: shared_mem_cache.h:46
Definition: system_cache_path.h:49
void set_thread_limit(int thread_limit)
Definition: system_caches.h:127
Definition: rewrite_driver_factory.h:70