Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
threadsafe_cache.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 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_THREADSAFE_CACHE_H_
20 #define PAGESPEED_KERNEL_CACHE_THREADSAFE_CACHE_H_
21 
28 #include "pagespeed/kernel/base/thread_annotations.h"
29 #include "pagespeed/kernel/cache/cache_interface.h"
30 
31 namespace net_instaweb {
32 
42  public:
45  : cache_(cache),
46  mutex_(mutex) {
47  }
48  virtual ~ThreadsafeCache();
49 
50  virtual void Get(const GoogleString& key, Callback* callback);
51  virtual void Put(const GoogleString& key, const SharedString& value)
52  LOCKS_EXCLUDED(mutex_);
53  virtual void Delete(const GoogleString& key) LOCKS_EXCLUDED(mutex_);
54  virtual CacheInterface* Backend() { return cache_; }
55  virtual bool IsBlocking() const { return cache_->IsBlocking(); }
56  virtual bool IsHealthy() const LOCKS_EXCLUDED(mutex_);
57  virtual void ShutDown() LOCKS_EXCLUDED(mutex_);
58 
59  static GoogleString FormatName(StringPiece cache);
60  virtual GoogleString Name() const { return FormatName(cache_->Name()); }
61 
62  private:
63  CacheInterface* cache_;
65 
66 
67 };
68 
69 }
70 
71 #endif
virtual void Get(const GoogleString &key, Callback *callback)
Abstract interface for a cache.
Definition: cache_interface.h:32
virtual void ShutDown() LOCKS_EXCLUDED(mutex_)
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
virtual CacheInterface * Backend()
Definition: threadsafe_cache.h:54
virtual void Put(const GoogleString &key, const SharedString &value) LOCKS_EXCLUDED(mutex_)
virtual GoogleString Name() const
Definition: threadsafe_cache.h:60
virtual bool IsHealthy() const LOCKS_EXCLUDED(mutex_)
Definition: scoped_ptr.h:30
Definition: threadsafe_cache.h:41
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
ThreadsafeCache(CacheInterface *cache, AbstractMutex *mutex)
Does not takes ownership of cache. Takes ownership of mutex.
Definition: threadsafe_cache.h:44
virtual bool IsBlocking() const =0
virtual bool IsBlocking() const
Definition: threadsafe_cache.h:55
Definition: shared_string.h:40
virtual GoogleString Name() const =0