19 #ifndef PAGESPEED_KERNEL_CACHE_FILE_CACHE_H_
20 #define PAGESPEED_KERNEL_CACHE_FILE_CACHE_H_
29 #include "pagespeed/kernel/base/thread_annotations.h"
32 namespace net_instaweb {
46 int64 target_size_bytes, int64 target_inode_count)
47 : timer(timer), hasher(hasher), clean_interval_ms(clean_interval_ms),
48 target_size_bytes(target_size_bytes),
49 target_inode_count(target_inode_count) {}
52 int64 clean_interval_ms;
53 int64 target_size_bytes;
54 int64 target_inode_count;
70 void set_worker(
SlowWorker* worker) { worker_ = worker; }
81 CachePolicy* mutable_cache_policy() {
return cache_policy_.get(); }
97 static const char kWriteErrors[];
104 class CacheCleanFunction;
105 friend class FileCacheTest;
106 friend class CacheCleanFunction;
113 bool Clean(int64 target_size_bytes, int64 target_inode_count);
117 void CleanWithLocking(int64 next_clean_time_ms) LOCKS_EXCLUDED(mutex_);
121 bool ShouldClean(int64* suggested_next_clean_time_ms) LOCKS_EXCLUDED(mutex_);
127 void CleanIfNeeded() LOCKS_EXCLUDED(mutex_);
137 int64 next_clean_ms_ GUARDED_BY(mutex_);
138 int path_length_limit_;
144 FileSystem::ProgressNotifier* notifier_for_tests_;
155 static const
char kCleanTimeName[];
157 static const
char kCleanLockName[];
161 static const
int kLockTimeoutMs;
static const char kEvictions[]
Files evicted from cache during cleanup.
Definition: file_cache.h:91
Abstract interface for a cache.
Definition: cache_interface.h:32
Definition: statistics.h:43
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
virtual bool IsBlocking() const
Definition: file_cache.h:76
virtual void Put(const GoogleString &key, const SharedString &value)
virtual bool IsHealthy() const
Definition: file_cache.h:77
static const char kSkippedCleanups[]
Definition: file_cache.h:94
virtual void ShutDown()
Definition: file_cache.h:78
Definition: scoped_ptr.h:30
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
virtual GoogleString Name() const
Definition: file_cache.h:74
static const int kDisableCleaning
Definition: file_cache.h:101
Definition: file_system.h:76
virtual void Get(const GoogleString &key, Callback *callback)
Definition: shared_string.h:40
Definition: file_cache.h:44
const CachePolicy * cache_policy() const
Definition: file_cache.h:80
Definition: cache_interface.h:42
Definition: thread_system.h:40
Definition: message_handler.h:39
static const char kDiskChecks[]
Number of times we checked disk usage in preparation from cleanup.
Definition: file_cache.h:89
static const char kCleanups[]
Number of times we actually cleaned cache because usage was high enough.
Definition: file_cache.h:87
Simple C++ implementation of file cache.
Definition: file_cache.h:42
static const char kBytesFreedInCleanup[]
Variable names.
Definition: file_cache.h:85
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
static const char kStartedCleanups[]
Number of times we scanned the cache to see if it needed cleaning.
Definition: file_cache.h:96
See file comment.
Definition: slow_worker.h:35