1 #include "libmemcached/memcached.h"
10 memcached_result_st result;
19 memcached_create(&memc);
22 Memcached(memcached_st *clone)
27 memcached_clone(&memc, clone);
32 memcached_free(&memc);
35 std::string fetch(const std::string& key, size_t *key_length, size_t *value_length)
41 char *value= memcached_fetch(&memc, const_cast<char *>(key.c_str()), key_length,
42 value_length, &flags, &rc);
45 ret_val.assign(value);
50 std::string get(const std::string& key, size_t *value_length)
56 char *value= memcached_get(&memc, key.c_str(), key.length(),
57 value_length, &flags, &rc);
60 ret_val.assign(value);
65 std::string get_by_key(const std::string& master_key,
66 const std::string& key,
73 char *value= memcached_get_by_key(&memc, master_key.c_str(), master_key.length(),
74 key.c_str(), key.length(),
75 value_length, &flags, &rc);
78 ret_val.assign(value);
83 memcached_return mget(char **keys, size_t *key_length,
84 unsigned int number_of_keys)
87 return memcached_mget(&memc, keys, key_length, number_of_keys);
90 memcached_return set(const std::string& key, const char *value, size_t value_length)
92 return memcached_set(&memc, key.c_str(), key.length(),
94 time_t(0), uint32_t(0));
97 memcached_return set_by_key(const std::string& master_key,
98 const std::string& key,
99 const char *value, size_t value_length)
101 return memcached_set_by_key(&memc, master_key.c_str(),
103 key.c_str(), key.length(),
110 increment(const std::string& key, unsigned int offset, uint64_t *value)
112 return memcached_increment(&memc, key.c_str(), key.length(),
117 decrement(const char *key, unsigned int offset, uint64_t *value)
119 return memcached_decrement(&memc, key, strlen(key),
124 memcached_return add(const char *key, const char *value, size_t value_length)
126 return memcached_add(&memc, key, strlen(key), value, value_length, 0, 0);
129 memcached_return add_by_key(const char *master_key, const char *key,
130 const char *value, size_t value_length)
132 return memcached_add_by_key(&memc, master_key, strlen(master_key),
138 memcached_return replace(const char *key, const char *value,
141 return memcached_replace(&memc, key, strlen(key),
146 memcached_return replace_by_key(const char *master_key, const char *key,
147 const char *value, size_t value_length)
149 return memcached_replace_by_key(&memc, master_key, strlen(master_key),
151 value, value_length, 0, 0);
154 memcached_return prepend(const char *key, const char *value,
157 return memcached_prepend(&memc, key, strlen(key),
158 value, value_length, 0, 0);
161 memcached_return prepend_by_key(const char *master_key, const char *key,
162 const char *value, size_t value_length)
164 return memcached_prepend_by_key(&memc, master_key, strlen(master_key),
171 memcached_return append(const char *key, const char *value,
174 return memcached_append(&memc, key, strlen(key),
175 value, value_length, 0, 0);
178 memcached_return append_by_key(const char *master_key, const char *key,
179 const char *value, size_t value_length)
181 return memcached_append_by_key(&memc,
182 master_key, strlen(master_key),
184 value, value_length, 0, 0);
187 memcached_return cas(const char *key, const char *value,
188 size_t value_length, uint64_t cas_arg)
190 return memcached_cas(&memc, key, strlen(key),
191 value, value_length, 0, 0, cas_arg);
194 memcached_return cas_by_key(const char *master_key, const char *key,
195 const char *value, size_t value_length,
198 return memcached_cas_by_key(&memc,
199 master_key, strlen(master_key),
205 // using 'remove' vs. 'delete' since 'delete' is a keyword
206 memcached_return remove(const char *key)
208 return memcached_delete (&memc, key, strlen(key), 0);
212 memcached_return delete_by_key(const char *master_key, const char *key)
214 return memcached_delete_by_key(&memc, master_key, strlen(master_key),
215 key, strlen(key), 0);