Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cache_property_store.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
24 
25 #ifndef PAGESPEED_OPT_HTTP_CACHE_PROPERTY_STORE_H_
26 #define PAGESPEED_OPT_HTTP_CACHE_PROPERTY_STORE_H_
27 
28 #include <map>
29 
37 
38 namespace net_instaweb {
39 
40 class PropertyCacheValues;
41 class Statistics;
42 class ThreadSystem;
43 class Timer;
44 
46  public:
48  static const char kPagePropertyCacheKeyPrefix[];
49 
53  CachePropertyStore(const GoogleString& cache_key_prefix,
54  CacheInterface* cache,
55  Timer* timer,
56  Statistics* stats,
57  ThreadSystem* thread_system);
58  virtual ~CachePropertyStore();
59 
63  virtual void Get(const GoogleString& url,
64  const GoogleString& options_signature_hash,
65  const GoogleString& cache_key_suffix,
66  const PropertyCache::CohortVector& cohort_list,
67  PropertyPage* page,
68  BoolCallback* done,
70 
72  virtual void Put(const GoogleString& url,
73  const GoogleString& options_signature_hash,
74  const GoogleString& cache_key_suffix,
75  const PropertyCache::Cohort* cohort,
76  const PropertyCacheValues* values,
77  BoolCallback* done);
78 
80  void AddCohort(const GoogleString& cohort);
83  void AddCohortWithCache(const GoogleString& cohort,
84  CacheInterface* cache);
85 
90  GoogleString CacheKey(const StringPiece& url,
91  const StringPiece& options_signature_hash,
92  const StringPiece& cache_key_suffix,
93  const PropertyCache::Cohort* cohort) const;
94 
96  const CacheInterface* cache_backend() { return default_cache_; }
97 
98  virtual GoogleString Name() const;
99 
100  static GoogleString FormatName3(StringPiece cohort_name1,
101  StringPiece cohort_cache1,
102  StringPiece cohort_name2,
103  StringPiece cohort_cache2,
104  StringPiece cohort_name3,
105  StringPiece cohort_cache3);
106 
107  private:
108  GoogleString cache_key_prefix_;
109  typedef std::map<GoogleString, CacheInterface*> CohortCacheMap;
110  CohortCacheMap cohort_cache_map_;
111  CacheInterface* default_cache_;
112  Timer* timer_;
113  Statistics* stats_;
114  ThreadSystem* thread_system_;
115 
116 };
117 
118 }
119 #endif
Abstract interface for a cache.
Definition: cache_interface.h:32
static const char kPagePropertyCacheKeyPrefix[]
Property cache key prefixes.
Definition: cache_property_store.h:48
Definition: property_cache.h:186
Definition: property_store.h:41
void AddCohortWithCache(const GoogleString &cohort, CacheInterface *cache)
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
virtual GoogleString Name() const
Definition: abstract_property_store_get_callback.h:31
const CacheInterface * cache_backend()
Returns default cache backend associated with CachePropertyStore.
Definition: cache_property_store.h:96
Definition: property_cache.h:323
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
void AddCohort(const GoogleString &cohort)
Establishes a Cohort backed by the CacheInteface passed to the constructor.
GoogleString CacheKey(const StringPiece &url, const StringPiece &options_signature_hash, const StringPiece &cache_key_suffix, const PropertyCache::Cohort *cohort) const
virtual void Put(const GoogleString &url, const GoogleString &options_signature_hash, const GoogleString &cache_key_suffix, const PropertyCache::Cohort *cohort, const PropertyCacheValues *values, BoolCallback *done)
Write to cache.
virtual void Get(const GoogleString &url, const GoogleString &options_signature_hash, const GoogleString &cache_key_suffix, const PropertyCache::CohortVector &cohort_list, PropertyPage *page, BoolCallback *done, AbstractPropertyStoreGetCallback **callback)
Definition: cache_property_store.h:45
Definition: thread_system.h:40
CachePropertyStore(const GoogleString &cache_key_prefix, CacheInterface *cache, Timer *timer, Statistics *stats, ThreadSystem *thread_system)
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
Definition: callback.h:44