Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
delay_cache.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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 
28 
29 #ifndef PAGESPEED_KERNEL_CACHE_DELAY_CACHE_H_
30 #define PAGESPEED_KERNEL_CACHE_DELAY_CACHE_H_
31 
32 #include <map>
33 
41 #include "pagespeed/kernel/cache/cache_interface.h"
43 
44 namespace net_instaweb {
45 
47 class DelayCache : public CacheInterface {
48  public:
50  DelayCache(CacheInterface* cache, ThreadSystem* thread_system);
51  virtual ~DelayCache();
52 
54  virtual void Get(const GoogleString& key, Callback* callback);
55  virtual void Put(const GoogleString& key, const SharedString& value);
56  virtual void Delete(const GoogleString& key);
57  virtual void MultiGet(MultiGetRequest* request);
58 
62  void DelayKey(const GoogleString& key);
63 
66  void ReleaseKey(const GoogleString& key) { ReleaseKeyInSequence(key, NULL); }
67 
71  void ReleaseKeyInSequence(const GoogleString& key,
72  QueuedWorkerPool::Sequence* sequence);
73 
74  static GoogleString FormatName(StringPiece name);
75  virtual GoogleString Name() const { return FormatName(cache_->Name()); }
76 
77  virtual bool IsBlocking() const { return false; }
78  virtual bool IsHealthy() const { return cache_->IsHealthy(); }
79  virtual void ShutDown() { cache_->ShutDown(); }
80 
81  private:
82  class DelayCallback;
83  friend class DelayCallback;
84 
85  void LookupComplete(DelayCallback* callback);
86 
87  typedef std::map<GoogleString, DelayCallback*> DelayMap;
88 
89  CacheInterface* cache_;
91  StringSet delay_requests_;
92  DelayMap delay_map_;
93 
94 
95 };
96 
97 }
98 
99 #endif
Abstract interface for a cache.
Definition: cache_interface.h:32
void ReleaseKeyInSequence(const GoogleString &key, QueuedWorkerPool::Sequence *sequence)
See file comment.
Definition: delay_cache.h:47
virtual void MultiGet(MultiGetRequest *request)
virtual void Get(const GoogleString &key, Callback *callback)
Reimplementations of CacheInterface methods.
void DelayKey(const GoogleString &key)
Definition: scoped_ptr.h:30
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
virtual bool IsHealthy() const =0
DelayCache(CacheInterface *cache, ThreadSystem *thread_system)
Note: takes ownership of nothing.
Definition: queued_worker_pool.h:65
Definition: shared_string.h:40
virtual bool IsBlocking() const
Definition: delay_cache.h:77
Definition: cache_interface.h:42
virtual GoogleString Name() const
Definition: delay_cache.h:75
Definition: thread_system.h:40
virtual bool IsHealthy() const
Definition: delay_cache.h:78
virtual GoogleString Name() const =0
virtual void Put(const GoogleString &key, const SharedString &value)
virtual void ShutDown()
Definition: delay_cache.h:79
void ReleaseKey(const GoogleString &key)
Definition: delay_cache.h:66