00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00018
00019 #ifndef NET_INSTAWEB_HTTP_PUBLIC_WRITE_THROUGH_HTTP_CACHE_H_
00020 #define NET_INSTAWEB_HTTP_PUBLIC_WRITE_THROUGH_HTTP_CACHE_H_
00021
00022 #include <cstddef>
00023 #include "base/scoped_ptr.h"
00024 #include "net/instaweb/http/public/http_cache.h"
00025 #include "net/instaweb/util/public/basictypes.h"
00026 #include "net/instaweb/util/public/cache_interface.h"
00027 #include "net/instaweb/util/public/string.h"
00028
00029 namespace net_instaweb {
00030
00031 class CacheInterface;
00032 class Hasher;
00033 class HTTPValue;
00034 class MessageHandler;
00035 class Statistics;
00036 class Timer;
00037
00039 class WriteThroughHTTPCache : public HTTPCache {
00040 public:
00041 static const size_t kUnlimited;
00042
00044 WriteThroughHTTPCache(CacheInterface* cache1, CacheInterface* cache2,
00045 Timer* timer, Hasher* hasher, Statistics* statistics);
00046
00047 virtual ~WriteThroughHTTPCache();
00048
00050 virtual void SetIgnoreFailurePuts();
00051
00053 virtual void Find(const GoogleString& key, MessageHandler* handler,
00054 Callback* callback);
00055
00057 virtual void Delete(const GoogleString& key);
00058
00060 virtual void set_force_caching(bool force);
00061
00063 virtual void set_remember_not_cacheable_ttl_seconds(int64 value);
00064
00066 virtual void set_remember_fetch_failed_ttl_seconds(int64 value);
00067
00069 virtual void set_max_cacheable_response_content_length(int64 value);
00070
00072 virtual void RememberNotCacheable(const GoogleString& key,
00073 MessageHandler * handler);
00074
00076 virtual void RememberFetchFailed(const GoogleString& key,
00077 MessageHandler * handler);
00078
00083 void set_cache1_limit(size_t limit) { cache1_size_limit_ = limit; }
00084
00085 virtual const char* Name() const { return name_.c_str(); }
00086
00087 protected:
00089 virtual void PutInternal(const GoogleString& key, int64 start_us,
00090 HTTPValue* value);
00091
00092 private:
00093 void PutInCache1(const GoogleString& key, HTTPValue* value);
00094
00095 scoped_ptr<HTTPCache> cache1_;
00096 scoped_ptr<HTTPCache> cache2_;
00097 size_t cache1_size_limit_;
00098 GoogleString name_;
00099
00100 DISALLOW_COPY_AND_ASSIGN(WriteThroughHTTPCache);
00101 };
00102
00103 }
00104
00105 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_WRITE_THROUGH_HTTP_CACHE_H_