Page Speed Optimization Libraries  1.9.32.2
 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 NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_CACHE_PATH_H_
18 #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_CACHE_PATH_H_
19 
20 #include <set>
21 
22 #include "pagespeed/kernel/base/basictypes.h"
23 #include "pagespeed/kernel/base/scoped_ptr.h"
24 #include "pagespeed/kernel/base/string.h"
25 #include "pagespeed/kernel/base/string_util.h"
26 #include "pagespeed/kernel/base/thread_annotations.h"
27 #include "pagespeed/kernel/util/copy_on_write.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 
62  CacheInterface* lru_cache() { return lru_cache_; }
63 
65  CacheInterface* file_cache() { return file_cache_; }
66 
69  FileCache* file_cache_backend() { return file_cache_backend_; }
70  NamedLockManager* lock_manager() { return lock_manager_; }
71 
73  void RootInit();
74  void ChildInit(SlowWorker* cache_clean_worker);
75  void GlobalCleanup(MessageHandler* handler);
76 
80  void MergeConfig(const SystemRewriteOptions* config);
81 
84  void AddServerContext(SystemServerContext* server_context);
85 
87  void RemoveServerContext(SystemServerContext* server_context);
88 
93  void FlushCacheIfNecessary();
94 
95  PurgeContext* purge_context() { return purge_context_.get(); }
96 
97  private:
98  typedef std::set<SystemServerContext*> ServerContextSet;
99 
100  void FallBackToFileBasedLocking();
101  GoogleString LockManagerSegmentName() const;
102 
118  void MergeEntries(int64 config_value, bool config_was_set,
119  bool take_larger,
120  const char* name,
121  int64* policy_value, bool* has_explicit_policy);
122 
123 
125  void UpdateCachePurgeSet(const CopyOnWrite<PurgeSet>& purge_set);
126 
127  GoogleString path_;
128 
129  RewriteDriverFactory* factory_;
130  AbstractSharedMem* shm_runtime_;
131  scoped_ptr<SharedMemLockManager> shared_mem_lock_manager_;
132  scoped_ptr<FileSystemLockManager> file_system_lock_manager_;
133  NamedLockManager* lock_manager_;
134  FileCache* file_cache_backend_;
135  CacheInterface* lru_cache_;
136  CacheInterface* file_cache_;
137  bool clean_interval_explicitly_set_;
138  bool clean_size_explicitly_set_;
139  bool clean_inode_limit_explicitly_set_;
140  const SystemRewriteOptions* options_;
141 
142  scoped_ptr<PurgeContext> purge_context_;
143 
144  scoped_ptr<AbstractMutex> mutex_;
145  ServerContextSet server_context_set_ GUARDED_BY(mutex_);
146 };
147 
151 #define CACHE_STATISTICS 1
152 
153 }
154 
155 #endif
void AddServerContext(SystemServerContext *server_context)
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:69
CacheInterface * file_cache()
Per-machine file cache with any stats wrappers.
Definition: system_cache_path.h:65
Definition: system_rewrite_options.h:31
void GlobalCleanup(MessageHandler *handler)
only called in root process
void RemoveServerContext(SystemServerContext *server_context)
Disassociates a server context with this CachePath – used on shutdown.
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:62
Definition: rewrite_driver_factory.h:73