18 #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_CACHES_H_
19 #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_CACHES_H_
24 #include "pagespeed/kernel/base/basictypes.h"
25 #include "pagespeed/kernel/base/md5_hasher.h"
26 #include "pagespeed/kernel/base/scoped_ptr.h"
27 #include "pagespeed/kernel/base/string.h"
28 #include "pagespeed/kernel/base/string_util.h"
29 #include "pagespeed/kernel/sharedmem/shared_mem_cache.h"
31 namespace net_instaweb {
33 class AbstractSharedMem;
37 class NamedLockManager;
38 class QueuedWorkerPool;
39 class RewriteDriverFactory;
43 class SystemCachePath;
44 class SystemRewriteOptions;
63 static const char kMemcachedBlocking[];
64 static const char kShmCache[];
66 static const char kDefaultSharedMemoryPath[];
69 kDefaultStatFlags = 0,
75 static void InitStats(Statistics* statistics);
80 AbstractSharedMem* shm_runtime,
86 bool is_root_process()
const {
return is_root_process_; }
101 void ShutDown(MessageHandler* message_handler);
104 void SetupCaches(ServerContext* server_context,
bool enable_property_cache);
112 StringPiece name, int64 size_kb, GoogleString* error_msg);
139 typedef SharedMemCache<64> MetadataShmCache;
140 struct MetadataShmCacheInfo {
141 MetadataShmCacheInfo()
142 : cache_to_use(NULL), cache_backend(NULL), initialized(false) {}
145 CacheInterface* cache_to_use;
146 GoogleString segment;
147 MetadataShmCache* cache_backend;
153 struct MemcachedInterfaces {
154 MemcachedInterfaces() : async(NULL), blocking(NULL) {}
155 CacheInterface* async;
156 CacheInterface* blocking;
160 AprMemCache* NewAprMemCache(
const GoogleString& spec);
171 MemcachedInterfaces GetMemcached(SystemRewriteOptions* config);
175 MetadataShmCacheInfo* LookupShmMetadataCache(
const GoogleString& name);
181 MetadataShmCacheInfo* GetShmMetadataCacheOrDefault(
182 SystemRewriteOptions* config);
185 void SetupPcacheCohorts(ServerContext* server_context,
186 bool enable_property_cache);
188 scoped_ptr<SlowWorker> slow_worker_;
190 RewriteDriverFactory* factory_;
191 AbstractSharedMem* shared_mem_runtime_;
193 bool is_root_process_;
205 typedef std::map<GoogleString, SystemCachePath*> PathCacheMap;
206 PathCacheMap path_cache_map_;
223 typedef std::map<GoogleString, MemcachedInterfaces> MemcachedMap;
224 MemcachedMap memcached_map_;
225 scoped_ptr<QueuedWorkerPool> memcached_pool_;
226 std::vector<AprMemCache*> memcache_servers_;
230 typedef std::map<GoogleString, MetadataShmCacheInfo*> MetadataShmCacheMap;
233 MetadataShmCacheMap metadata_shm_caches_;
235 MD5Hasher cache_hasher_;
237 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:62
void SetupCaches(ServerContext *server_context, bool enable_property_cache)
Configures server_context's caches based on its configuration.
~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:31
void RegisterConfig(SystemRewriteOptions *config)
bool CreateShmMetadataCache(StringPiece name, int64 size_kb, GoogleString *error_msg)
SystemCaches(RewriteDriverFactory *factory, AbstractSharedMem *shm_runtime, int thread_limit)
SystemCachePath * GetCache(SystemRewriteOptions *config)
Definition: system_caches.h:59
static void InitStats(Statistics *statistics)
Registers all statistics the cache backends may use.
Definition: system_cache_path.h:49
void set_thread_limit(int thread_limit)
Definition: system_caches.h:123
Definition: rewrite_driver_factory.h:73