Merged
[m6w6/libmemcached] / include / 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 WATCHPOINT;
23 memcached_clone(&memc, clone);
24 WATCHPOINT;
25 }
26
27 char *get(char *key, size_t *value_length)
28 {
29 uint32_t flags;
30 memcached_return rc;
31
32 return memcached_get(&memc, key, strlen(key),
33 value_length, &flags, &rc);
34 }
35
36 char *get_by_key(char *key, char *master_key, size_t *value_length)
37 {
38 uint32_t flags;
39 memcached_return rc;
40
41 return memcached_get_by_key(&memc, key, strlen(key), master_key, strlen(master_key),
42 value_length, &flags, &rc);
43 }
44
45 memcached_return mget(char **keys, size_t *key_length, unsigned int number_of_keys)
46 {
47
48 return memcached_mget(&memc, keys, key_length, number_of_keys);
49 }
50
51 memcached_return set(char *key, char *value, size_t value_length)
52 {
53 return memcached_set(&memc, key, strlen(key),
54 value, value_length,
55 (time_t)0, (uint32_t)0);
56 }
57
58 memcached_return set_by_key(char *master_key, char *key, char *value, size_t value_length)
59 {
60 return memcached_set_by_key(&memc, master_key, strlen(master_key),
61 key, strlen(key),
62 value, value_length,
63 (time_t)0,
64 (uint32_t)0 );
65 }
66
67
68 memcached_return add(char *key, char *value, size_t value_length)
69 {
70 return memcached_add(&memc, key, strlen(key),
71 value, value_length,
72 (time_t)0, (uint32_t)0);
73 }
74
75 memcached_return replace(char *key, char *value, size_t value_length)
76 {
77 return memcached_replace(&memc, key, strlen(key),
78 value, value_length,
79 (time_t)0, (uint32_t)0);
80 }
81
82 memcached_return prepend(char *key, char *value, size_t value_length)
83 {
84 return memcached_prepend(&memc, key, strlen(key),
85 value, value_length,
86 (time_t)0,
87 (uint32_t)0);
88 }
89
90
91 memcached_return append(char *key, char *value, size_t value_length)
92 {
93 return memcached_append(&memc, key, strlen(key),
94 value, value_length,
95 (time_t)0,
96 (uint32_t)0);
97 }
98 ~Memcached()
99 {
100 memcached_free(&memc);
101 }
102 };