--- a/memcache/memcache.c Thu Aug 28 00:29:39 2008 +0300
+++ b/memcache/memcache.c Thu Aug 28 01:34:14 2008 +0300
@@ -50,12 +50,12 @@
return mc->server_list.lh_first;
}
-struct memcache_req *memcache_fetch (struct memcache *mc, const struct memcache_key *key, void *cb_arg) {
+static struct memcache_req *_memcache_req (struct memcache *mc, enum memcache_command cmd, const struct memcache_key *key, const struct memcache_obj *obj, const struct memcache_buf *buf, void *cb_arg) {
struct memcache_req *req = NULL;
struct memcache_server *server = NULL;
// alloc the request
- if ((req = memcache_req_alloc(mc, MEMCACHE_CMD_FETCH_GET, key, cb_arg)) == NULL)
+ if ((req = memcache_req_alloc(mc, MEMCACHE_CMD_FETCH_GET, key, obj, buf, cb_arg)) == NULL)
ERROR("failed to allocate request");
// pick a server
@@ -76,3 +76,24 @@
return NULL;
}
+struct memcache_req *memcache_fetch (struct memcache *mc, const struct memcache_key *key, void *cb_arg) {
+ return _memcache_req(mc, MEMCACHE_CMD_FETCH_GET, key, NULL, NULL, cb_arg);
+}
+
+struct memcache_req *memcache_store (struct memcache *mc, enum memcache_command cmd, const struct memcache_key *key, const struct memcache_obj *obj, const struct memcache_buf *buf, void *cb_arg) {
+ if (
+ (cmd != MEMCACHE_CMD_STORE_SET)
+ && (cmd != MEMCACHE_CMD_STORE_ADD)
+ && (cmd != MEMCACHE_CMD_STORE_REPLACE)
+ && (cmd != MEMCACHE_CMD_STORE_APPEND)
+ && (cmd != MEMCACHE_CMD_STORE_PREPEND)
+ && (cmd != MEMCACHE_CMD_STORE_CAS)
+ )
+ ERROR("invalid command for store");
+
+ return _memcache_req(mc, cmd, key, obj, buf, cb_arg);
+
+error:
+ return NULL;
+}
+