New version update
[m6w6/libmemcached] / libmemcached / memcached.hh
1 #ifdef USE_PRAGMA_INTERFACE
2 #pragma interface /* gcc class implementation */
3 #endif
4
5 #include <memcached.h>
6 #include <string.h>
7 #include <stdio.h>
8
9 class Memcached
10 {
11 memcached_st memc;
12
13 public:
14
15 Memcached()
16 {
17 memcached_create(&memc);
18 }
19
20 Memcached(memcached_st *clone)
21 {
22 memcached_clone(&memc, clone);
23 }
24
25 char *get(char *key, size_t *value_length)
26 {
27 uint32_t flags;
28 memcached_return rc;
29
30 return memcached_get(&memc, key, strlen(key),
31 value_length, &flags, &rc);
32 }
33
34 char *get_by_key(char *master_key, char *key, size_t *value_length)
35 {
36 uint32_t flags;
37 memcached_return rc;
38
39 return memcached_get_by_key(&memc, master_key, strlen(master_key), key, strlen(key),
40 value_length, &flags, &rc);
41 }
42
43 memcached_return mget(char **keys, size_t *key_length, unsigned int number_of_keys)
44 {
45
46 return memcached_mget(&memc, keys, key_length, number_of_keys);
47 }
48
49 memcached_return set(char *key, char *value, size_t value_length)
50 {
51 return memcached_set(&memc, key, strlen(key),
52 value, value_length,
53 (time_t)0, (uint32_t)0);
54 }
55
56 memcached_return set_by_key(char *master_key, char *key, char *value, size_t value_length)
57 {
58 return memcached_set_by_key(&memc, master_key, strlen(master_key),
59 key, strlen(key),
60 value, value_length,
61 (time_t)0,
62 (uint32_t)0 );
63 }
64
65
66 memcached_return add(char *key, char *value, size_t value_length)
67 {
68 return memcached_add(&memc, key, strlen(key),
69 value, value_length,
70 (time_t)0, (uint32_t)0);
71 }
72
73 memcached_return replace(char *key, char *value, size_t value_length)
74 {
75 return memcached_replace(&memc, key, strlen(key),
76 value, value_length,
77 (time_t)0, (uint32_t)0);
78 }
79
80 memcached_return prepend(char *key, char *value, size_t value_length)
81 {
82 return memcached_prepend(&memc, key, strlen(key),
83 value, value_length,
84 (time_t)0,
85 (uint32_t)0);
86 }
87
88
89 memcached_return append(char *key, char *value, size_t value_length)
90 {
91 return memcached_append(&memc, key, strlen(key),
92 value, value_length,
93 (time_t)0,
94 (uint32_t)0);
95 }
96 ~Memcached()
97 {
98 memcached_free(&memc);
99 }
100 };