Page Speed Optimization Libraries  1.8.31.3
net/instaweb/system/public/system_cache_path.h
Go to the documentation of this file.
00001 // Copyright 2011 Google Inc.
00016 
00017 #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_CACHE_PATH_H_
00018 #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_CACHE_PATH_H_
00019 
00020 #include "net/instaweb/util/public/scoped_ptr.h"
00021 #include "net/instaweb/util/public/string.h"
00022 #include "net/instaweb/util/public/string_util.h"
00023 #include "pagespeed/kernel/base/basictypes.h"
00024 
00025 namespace net_instaweb {
00026 
00027 class AbstractSharedMem;
00028 class CacheInterface;
00029 class FileCache;
00030 class FileSystemLockManager;
00031 class MessageHandler;
00032 class NamedLockManager;
00033 class RewriteDriverFactory;
00034 class SharedMemLockManager;
00035 class SlowWorker;
00036 class SystemRewriteOptions;
00037 
00041 class SystemCachePath {
00042  public:
00044   static const char kFileCache[];
00045   static const char kLruCache[];
00046 
00047   SystemCachePath(const StringPiece& path,
00048                   const SystemRewriteOptions* config,
00049                   RewriteDriverFactory* factory,
00050                   AbstractSharedMem* shm_runtime);
00051   ~SystemCachePath();
00052 
00054   CacheInterface* lru_cache() { return lru_cache_; }
00055 
00057   CacheInterface* file_cache() { return file_cache_; }
00058 
00061   FileCache* file_cache_backend() { return file_cache_backend_; }
00062   NamedLockManager* lock_manager() { return lock_manager_; }
00063 
00065   void RootInit();
00066   void ChildInit(SlowWorker* cache_clean_worker);
00067   void GlobalCleanup(MessageHandler* handler); 
00068 
00072   void MergeConfig(const SystemRewriteOptions* config);
00073 
00074  private:
00075   void FallBackToFileBasedLocking();
00076   GoogleString LockManagerSegmentName() const;
00077 
00093   void MergeEntries(int64 config_value, bool config_was_set,
00094                     bool take_larger,
00095                     const char* name,
00096                     int64* policy_value, bool* has_explicit_policy);
00097 
00098   GoogleString path_;
00099 
00100   RewriteDriverFactory* factory_;
00101   AbstractSharedMem* shm_runtime_;
00102   scoped_ptr<SharedMemLockManager> shared_mem_lock_manager_;
00103   scoped_ptr<FileSystemLockManager> file_system_lock_manager_;
00104   NamedLockManager* lock_manager_;
00105   FileCache* file_cache_backend_; 
00106   CacheInterface* lru_cache_;
00107   CacheInterface* file_cache_;
00108   bool clean_interval_explicitly_set_;
00109   bool clean_size_explicitly_set_;
00110   bool clean_inode_limit_explicitly_set_;
00111 };
00112 
00116 #define CACHE_STATISTICS 1
00117 
00118 }  
00119 
00120 #endif  ///< NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_CACHE_PATH_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines