Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
system_cache_path.h
Go to the documentation of this file.
1 // Copyright 2011 Google Inc.
16 
17 #ifndef PAGESPEED_SYSTEM_SYSTEM_CACHE_PATH_H_
18 #define PAGESPEED_SYSTEM_SYSTEM_CACHE_PATH_H_
19 
20 #include <set>
21 
26 #include "pagespeed/kernel/base/thread_annotations.h"
28 
29 namespace net_instaweb {
30 
31 class AbstractMutex;
32 class AbstractSharedMem;
33 class CacheInterface;
34 class FileCache;
35 class FileSystemLockManager;
36 class MessageHandler;
37 class NamedLockManager;
38 class PurgeContext;
39 class PurgeSet;
40 class RewriteDriverFactory;
41 class SharedMemLockManager;
42 class SlowWorker;
43 class SystemServerContext;
44 class SystemRewriteOptions;
45 
50  public:
52  static const char kFileCache[];
53  static const char kLruCache[];
54 
55  SystemCachePath(const StringPiece& path,
56  const SystemRewriteOptions* config,
57  RewriteDriverFactory* factory,
58  AbstractSharedMem* shm_runtime);
59  ~SystemCachePath();
60 
64 
66  CacheInterface* lru_cache() { return lru_cache_; }
67 
69  CacheInterface* file_cache() { return file_cache_; }
70 
73  FileCache* file_cache_backend() { return file_cache_backend_; }
74  NamedLockManager* lock_manager() { return lock_manager_; }
75 
77  void RootInit();
78  void ChildInit(SlowWorker* cache_clean_worker);
79  void GlobalCleanup(MessageHandler* handler);
80 
84  void MergeConfig(const SystemRewriteOptions* config);
85 
88  void AddServerContext(SystemServerContext* server_context);
89 
91  void RemoveServerContext(SystemServerContext* server_context);
92 
97  void FlushCacheIfNecessary();
98 
99  PurgeContext* purge_context() { return purge_context_.get(); }
100 
101  private:
102  typedef std::set<SystemServerContext*> ServerContextSet;
103 
104  void FallBackToFileBasedLocking();
105  GoogleString LockManagerSegmentName() const;
106 
122  void MergeEntries(int64 config_value, bool config_was_set,
123  bool take_larger,
124  const char* name,
125  int64* policy_value, bool* has_explicit_policy);
126 
127 
129  void UpdateCachePurgeSet(const CopyOnWrite<PurgeSet>& purge_set);
130 
131  GoogleString path_;
132 
133  RewriteDriverFactory* factory_;
134  AbstractSharedMem* shm_runtime_;
135  scoped_ptr<SharedMemLockManager> shared_mem_lock_manager_;
136  scoped_ptr<FileSystemLockManager> file_system_lock_manager_;
137  NamedLockManager* lock_manager_;
138  FileCache* file_cache_backend_;
139  CacheInterface* lru_cache_;
140  CacheInterface* file_cache_;
141  GoogleString cache_flush_filename_;
142  bool unplugged_;
143  bool enable_cache_purge_;
144  bool clean_interval_explicitly_set_;
145  bool clean_size_explicitly_set_;
146  bool clean_inode_limit_explicitly_set_;
147 
148  scoped_ptr<PurgeContext> purge_context_;
149 
150  scoped_ptr<AbstractMutex> mutex_;
151  ServerContextSet server_context_set_ GUARDED_BY(mutex_);
152 };
153 
154 }
155 
156 #endif
void AddServerContext(SystemServerContext *server_context)
Abstract interface for a cache.
Definition: cache_interface.h:32
Definition: named_lock_manager.h:82
static const char kFileCache[]
CacheStats prefixes.
Definition: system_cache_path.h:52
void MergeConfig(const SystemRewriteOptions *config)
void RootInit()
See comments in SystemCaches for calling conventions on these.
FileCache * file_cache_backend()
Definition: system_cache_path.h:73
CacheInterface * file_cache()
Per-machine file cache with any stats wrappers.
Definition: system_cache_path.h:69
Definition: system_rewrite_options.h:40
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
void GlobalCleanup(MessageHandler *handler)
only called in root process
Definition: abstract_shared_mem.h:86
void RemoveServerContext(SystemServerContext *server_context)
Disassociates a server context with this CachePath – used on shutdown.
static GoogleString CachePath(SystemRewriteOptions *config)
Simple C++ implementation of file cache.
Definition: file_cache.h:42
Definition: system_cache_path.h:49
CacheInterface * lru_cache()
Per-process in-memory LRU, with any stats/thread safety wrappers, or NULL.
Definition: system_cache_path.h:66
Definition: rewrite_driver_factory.h:70