19 #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_APR_MEM_CACHE_H_
20 #define NET_INSTAWEB_SYSTEM_PUBLIC_APR_MEM_CACHE_H_
27 #include "net/instaweb/util/public/cache_interface.h"
32 struct apr_memcache2_t;
33 struct apr_memcache2_server_t;
36 namespace net_instaweb {
75 AprMemCache(
const StringPiece& servers,
int thread_limit, Hasher* hasher,
76 Statistics* statistics, Timer* timer, MessageHandler* handler);
79 static void InitStats(Statistics* statistics);
81 const GoogleString& server_spec()
const {
return server_spec_; }
84 virtual void Get(
const GoogleString& key, Callback* callback);
85 virtual void Put(
const GoogleString& key, SharedString* value);
86 virtual void Delete(
const GoogleString& key);
87 virtual void MultiGet(MultiGetRequest* request);
93 bool valid_server_spec()
const {
return valid_server_spec_; }
97 bool GetStatus(GoogleString* status_string);
99 static GoogleString FormatName() {
return "AprMemCache"; }
100 virtual GoogleString Name()
const {
return FormatName(); }
102 virtual bool IsBlocking()
const {
return true; }
118 virtual bool MustEncodeKeyInValueOnPut()
const {
return true; }
119 virtual void PutWithKeyInValue(
const GoogleString& key,
120 SharedString* key_and_value);
127 void DecodeValueMatchingKeyAndCallCallback(
128 const GoogleString& key,
const char* data,
size_t data_len,
129 const char* calling_method, Callback* callback);
134 void PutHelper(
const GoogleString& key, SharedString* key_and_value);
137 std::vector<int> ports_;
138 GoogleString server_spec_;
139 bool valid_server_spec_;
143 apr_memcache2_t* memcached_;
144 std::vector<apr_memcache2_server_t*> servers_;
147 AtomicBool shutdown_;
150 UpDownCounter* last_error_checkpoint_ms_;
151 UpDownCounter* error_burst_size_;
153 bool is_machine_local_;
154 MessageHandler* message_handler_;
167 Variable* last_apr_error_;
Definition: apr_mem_cache.h:50
static const int64 kMaxErrorBurst
Definition: apr_mem_cache.h:68
static const int64 kHealthCheckpointIntervalMs
Amount of time after a burst of errors to retry memcached operations.
Definition: apr_mem_cache.h:63
AprMemCache(const StringPiece &servers, int thread_limit, Hasher *hasher, Statistics *statistics, Timer *timer, MessageHandler *handler)
static const size_t kValueSizeThreshold
Definition: apr_mem_cache.h:60
bool GetStatus(GoogleString *status_string)
void set_timeout_us(int timeout_us)
virtual void ShutDown()
Close down the connection to the memcached servers.
virtual void Get(const GoogleString &key, Callback *callback)
As mentioned above, Get and MultiGet are blocking in this implementation.
virtual bool IsHealthy() const