source: src/client.h @ 34bb6d

Revision 34bb6d, 4.5 KB checked in by Tomash Brechko <tomash.brechko@…>, 3 years ago (diff)

Remove delay (aka expiration) parameter for delete() and delete_multi().

  • Property mode set to 100644
Line 
1/*
2  Copyright (C) 2007-2008 Tomash Brechko.  All rights reserved.
3
4  When used to build Perl module:
5
6  This library is free software; you can redistribute it and/or modify
7  it under the same terms as Perl itself, either Perl version 5.8.8
8  or, at your option, any later version of Perl 5 you may have
9  available.
10
11  When used as a standalone library:
12
13  This library is free software; you can redistribute it and/or modify
14  it under the terms of the GNU Lesser General Public License as
15  published by the Free Software Foundation; either version 2.1 of the
16  License, or (at your option) any later version.
17
18  This library is distributed in the hope that it will be useful, but
19  WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  Lesser General Public License for more details.
22*/
23
24#ifndef CLIENT_H
25#define CLIENT_H 1
26
27#include <stddef.h>
28
29
30struct client;
31
32
33enum server_status {
34  MEMCACHED_SUCCESS,
35  MEMCACHED_FAILURE,
36  MEMCACHED_EAGAIN,
37  MEMCACHED_ERROR,
38  MEMCACHED_UNKNOWN,
39  MEMCACHED_CLOSED
40};
41
42enum set_cmd_e { CMD_SET, CMD_ADD, CMD_REPLACE, CMD_APPEND, CMD_PREPEND,
43                 CMD_CAS };
44
45enum get_cmd_e { CMD_GET, CMD_GETS };
46
47enum arith_cmd_e { CMD_INCR, CMD_DECR };
48
49
50typedef unsigned int flags_type;
51#define FMT_FLAGS "%u"
52
53typedef int exptime_type;
54#define FMT_EXPTIME "%d"
55
56typedef unsigned int delay_type;
57#define FMT_DELAY "%u"
58
59typedef unsigned long value_size_type;
60#define FMT_VALUE_SIZE "%lu"
61
62typedef unsigned long long cas_type;
63#define FMT_CAS "%llu"
64
65typedef unsigned long long arith_type;
66#define FMT_ARITH "%llu"
67
68
69typedef void *(*alloc_value_func)(value_size_type value_size, void **opaque);
70typedef void (*store_value_func)(void *arg, void *opaque, int key_index,
71                                 void *meta);
72typedef void (*free_value_func)(void *opaque);
73
74struct result_object
75{
76  alloc_value_func alloc;
77  store_value_func store;
78  free_value_func free;
79
80  void *arg;
81};
82
83struct meta_object
84{
85  flags_type flags;
86  int use_cas;
87  cas_type cas;
88};
89
90
91extern
92struct client *
93client_init();
94
95extern
96void
97client_destroy(struct client *c);
98
99extern
100void
101client_reinit(struct client *c);
102
103/*
104  client_set_ketama_points() should be called before adding any server.
105*/
106extern
107int
108client_set_ketama_points(struct client *c, int ketama_points);
109
110/*
111  client_set_hash_namespace() should be called before setting the
112  namespace.
113*/
114extern
115void
116client_set_hash_namespace(struct client *c, int enable);
117
118extern
119int
120client_add_server(struct client *c, const char *host, size_t host_len,
121                  const char *port, size_t port_len, double weight,
122                  int noreply);
123
124extern
125int
126client_set_prefix(struct client *c, const char *ns, size_t ns_len);
127
128extern
129const char *
130client_get_prefix(struct client *c, size_t *ns_len);
131
132extern
133void
134client_set_connect_timeout(struct client *c, int to);
135
136extern
137void
138client_set_io_timeout(struct client *c, int to);
139
140extern
141void
142client_set_max_failures(struct client *c, int f);
143
144extern
145void
146client_set_failure_timeout(struct client *c, int to);
147
148extern
149void
150client_set_close_on_error(struct client *c, int enable);
151
152extern
153void
154client_set_nowait(struct client *c, int enable);
155
156extern
157void
158client_reset(struct client *c, struct result_object *o, int noreply);
159
160extern
161int
162client_prepare_set(struct client *c, enum set_cmd_e cmd, int key_index,
163                   const char *key, size_t key_len,
164                   flags_type flags, exptime_type exptime,
165                   const void *value, value_size_type value_size);
166
167extern
168int
169client_prepare_cas(struct client *c, int key_index,
170                   const char *key, size_t key_len,
171                   cas_type cas, flags_type flags, exptime_type exptime,
172                   const void *value, value_size_type value_size);
173
174extern
175int
176client_prepare_get(struct client *c, enum get_cmd_e cmd, int key_index,
177                   const char *key, size_t key_len);
178
179extern
180int
181client_prepare_incr(struct client *c, enum arith_cmd_e cmd, int key_index,
182                    const char *key, size_t key_len, arith_type arg);
183
184extern
185int
186client_prepare_delete(struct client *c, int key_index,
187                      const char *key, size_t key_len);
188
189extern
190int
191client_execute(struct client *c);
192
193extern
194int
195client_flush_all(struct client *c, delay_type delay,
196                 struct result_object *o, int noreply);
197
198extern
199int
200client_nowait_push(struct client *c);
201
202extern
203int
204client_server_versions(struct client *c, struct result_object *o);
205
206
207#endif /* ! CLIENT_H */
Note: See TracBrowser for help on using the repository browser.