Page Speed Optimization Libraries
1.7.30.4
|
00001 /* 00002 * Copyright 2013 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 00024 00025 #ifndef NET_INSTAWEB_UTIL_PUBLIC_CACHE_PROPERTY_STORE_H_ 00026 #define NET_INSTAWEB_UTIL_PUBLIC_CACHE_PROPERTY_STORE_H_ 00027 00028 #include <map> 00029 00030 #include "net/instaweb/util/public/property_cache.h" 00031 #include "net/instaweb/util/public/property_store.h" 00032 #include "pagespeed/kernel/base/basictypes.h" 00033 #include "pagespeed/kernel/base/string_util.h" 00034 #include "pagespeed/kernel/base/string.h" 00035 00036 namespace net_instaweb { 00037 00038 class AbstractPropertyStoreGetCallback; 00039 class CacheInterface; 00040 class PropertyCacheValues; 00041 class Statistics; 00042 class ThreadSystem; 00043 class Timer; 00044 00045 class CachePropertyStore : public PropertyStore { 00046 public: 00048 static const char kPagePropertyCacheKeyPrefix[]; 00049 00053 CachePropertyStore(const GoogleString& cache_key_prefix, 00054 CacheInterface* cache, 00055 Timer* timer, 00056 Statistics* stats, 00057 ThreadSystem* thread_system); 00058 virtual ~CachePropertyStore(); 00059 00063 virtual void Get(const GoogleString& url, 00064 const GoogleString& options_signature_hash, 00065 const GoogleString& cache_key_suffix, 00066 const PropertyCache::CohortVector& cohort_list, 00067 PropertyPage* page, 00068 BoolCallback* done, 00069 AbstractPropertyStoreGetCallback** callback); 00070 00072 virtual void Put(const GoogleString& url, 00073 const GoogleString& options_signature_hash, 00074 const GoogleString& cache_key_suffix, 00075 const PropertyCache::Cohort* cohort, 00076 const PropertyCacheValues* values, 00077 BoolCallback* done); 00078 00080 void AddCohort(const GoogleString& cohort); 00083 void AddCohortWithCache(const GoogleString& cohort, 00084 CacheInterface* cache); 00085 00090 GoogleString CacheKey(const StringPiece& url, 00091 const StringPiece& options_signature_hash, 00092 const StringPiece& cache_key_suffix, 00093 const PropertyCache::Cohort* cohort) const; 00094 00096 const CacheInterface* cache_backend() { return default_cache_; } 00097 00098 virtual GoogleString Name() const; 00099 00100 static GoogleString FormatName2(StringPiece cohort_name1, 00101 StringPiece cohort_cache1, 00102 StringPiece cohort_name2, 00103 StringPiece cohort_cache2); 00104 00105 private: 00106 GoogleString cache_key_prefix_; 00107 typedef std::map<GoogleString, CacheInterface*> CohortCacheMap; 00108 CohortCacheMap cohort_cache_map_; 00109 CacheInterface* default_cache_; 00110 Timer* timer_; 00111 Statistics* stats_; 00112 ThreadSystem* thread_system_; 00113 DISALLOW_COPY_AND_ASSIGN(CachePropertyStore); 00114 }; 00115 00116 } 00117 #endif ///< NET_INSTAWEB_UTIL_PUBLIC_CACHE_PROPERTY_STORE_H_