Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cache_key_prepender.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 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 
18 
19 #ifndef PAGESPEED_KERNEL_CACHE_CACHE_KEY_PREPENDER_H_
20 #define PAGESPEED_KERNEL_CACHE_CACHE_KEY_PREPENDER_H_
21 
26 #include "pagespeed/kernel/cache/cache_interface.h"
27 
28 namespace net_instaweb {
29 
34  public:
36  CacheKeyPrepender(StringPiece prefix, CacheInterface* cache);
37  ~CacheKeyPrepender() override {}
38 
40  void Get(const GoogleString& key, Callback* callback) override;
41  void MultiGet(MultiGetRequest* request) override;
42  void Put(const GoogleString& key, const SharedString& value) override;
43  void Delete(const GoogleString& key) override;
44  CacheInterface* Backend() override { return cache_; }
45  bool IsBlocking() const override { return cache_->IsBlocking(); }
46 
48  bool IsHealthy() const override { return cache_->IsHealthy(); }
49  void ShutDown() override { cache_->ShutDown(); }
50  GoogleString Name() const override {
51  return FormatName(prefix_.Value(), cache_->Name());
52  }
53 
54  static GoogleString FormatName(StringPiece prefix, StringPiece cache);
55 
56  private:
57  class KeyPrependerCallback;
58 
59  CacheInterface* cache_;
60  SharedString prefix_;
61 
62  GoogleString AddPrefix(const GoogleString &key);
63 
64 
65 };
66 
67 }
68 
69 #endif
Abstract interface for a cache.
Definition: cache_interface.h:32
CacheInterface * Backend() override
Definition: cache_key_prepender.h:44
bool IsBlocking() const override
Definition: cache_key_prepender.h:45
Definition: cache_key_prepender.h:33
StringPiece Value() const
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
void ShutDown() override
Definition: cache_key_prepender.h:49
virtual bool IsHealthy() const =0
virtual bool IsBlocking() const =0
bool IsHealthy() const override
Implementation of CacheInterface.
Definition: cache_key_prepender.h:48
void Get(const GoogleString &key, Callback *callback) override
Implementation of CacheInterface.
Definition: shared_string.h:40
void Put(const GoogleString &key, const SharedString &value) override
Definition: cache_interface.h:42
CacheKeyPrepender(StringPiece prefix, CacheInterface *cache)
Does not takes ownership of the cache.
GoogleString Name() const override
Definition: cache_key_prepender.h:50
virtual GoogleString Name() const =0
void MultiGet(MultiGetRequest *request) override