Page Speed Optimization Libraries
1.2.24.1
|
00001 /* 00002 * Copyright 2011 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 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 00024 #include "net/instaweb/http/public/http_cache.h" 00025 #include "net/instaweb/util/public/basictypes.h" 00026 #include "net/instaweb/util/public/scoped_ptr.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_hasher(Hasher* hasher) { 00064 cache1_->set_hasher(hasher); 00065 cache2_->set_hasher(hasher); 00066 } 00067 00069 virtual void set_disable_html_caching_on_https(bool x); 00070 00072 virtual void set_remember_not_cacheable_ttl_seconds(int64 value); 00073 00075 virtual void set_remember_fetch_failed_ttl_seconds(int64 value); 00076 00078 virtual void set_remember_fetch_dropped_ttl_seconds(int64 value); 00079 00081 virtual void set_max_cacheable_response_content_length(int64 value); 00082 00084 virtual void RememberNotCacheable(const GoogleString& key, 00085 bool is_200_status_code, 00086 MessageHandler * handler); 00087 00089 virtual void RememberFetchFailed(const GoogleString& key, 00090 MessageHandler * handler); 00091 00093 virtual void RememberFetchDropped(const GoogleString& key, 00094 MessageHandler * handler); 00095 00100 void set_cache1_limit(size_t limit) { cache1_size_limit_ = limit; } 00101 00102 virtual const char* Name() const { return name_.c_str(); } 00103 00104 protected: 00106 virtual void PutInternal(const GoogleString& key, int64 start_us, 00107 HTTPValue* value); 00108 00109 private: 00110 void PutInCache1(const GoogleString& key, HTTPValue* value); 00111 00112 scoped_ptr<HTTPCache> cache1_; 00113 scoped_ptr<HTTPCache> cache2_; 00114 size_t cache1_size_limit_; 00115 GoogleString name_; 00116 00117 DISALLOW_COPY_AND_ASSIGN(WriteThroughHTTPCache); 00118 }; 00119 00120 } 00121 00122 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_WRITE_THROUGH_HTTP_CACHE_H_