memcached 1.4.3 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +4 -0
- data/Manifest +3 -0
- data/Rakefile +29 -6
- data/ext/libmemcached-0.32/configure.lineno +23825 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.am +5 -3
- data/ext/libmemcached-0.32/libmemcached/Makefile.in +16 -8
- data/ext/libmemcached-0.32/libmemcached/common.h +9 -3
- data/ext/libmemcached-0.32/libmemcached/memcached.h +1 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_do.c +37 -1
- data/ext/libmemcached-0.32/libmemcached/memcached_exist.c +114 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_exist.h +20 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.c +33 -5
- data/ext/libmemcached-0.32/libmemcached/memcached_io.h +15 -2
- data/ext/rlibmemcached_wrap.c +1138 -1098
- data/lib/memcached/memcached.rb +9 -0
- data/lib/memcached/rails.rb +1 -1
- data/memcached.gemspec +3 -3
- data/test/profile/benchmark.rb +15 -0
- data/test/unit/memcached_test.rb +24 -0
- data/test/unit/rails_test.rb +5 -3
- metadata +5 -2
- metadata.gz.sig +0 -0
|
@@ -14,9 +14,10 @@ pkginclude_HEADERS= memcached.h \
|
|
|
14
14
|
memcached.hpp \
|
|
15
15
|
memcached_configure.h \
|
|
16
16
|
memcached_constants.h \
|
|
17
|
+
memcached_exist.h \
|
|
17
18
|
memcached_get.h \
|
|
18
19
|
memcached_result.h \
|
|
19
|
-
|
|
20
|
+
memcached_sasl.h \
|
|
20
21
|
memcached_server.h \
|
|
21
22
|
memcached_storage.h \
|
|
22
23
|
memcached_string.h \
|
|
@@ -45,6 +46,7 @@ libmemcached_la_SOURCES = crc.c \
|
|
|
45
46
|
memcached_delete.c \
|
|
46
47
|
memcached_do.c \
|
|
47
48
|
memcached_dump.c \
|
|
49
|
+
memcached_exist.c \
|
|
48
50
|
memcached_fetch.c \
|
|
49
51
|
memcached_flush.c \
|
|
50
52
|
memcached_get.c \
|
|
@@ -53,7 +55,7 @@ libmemcached_la_SOURCES = crc.c \
|
|
|
53
55
|
memcached_hosts.c \
|
|
54
56
|
memcached_io.c \
|
|
55
57
|
memcached_purge.c \
|
|
56
|
-
|
|
58
|
+
memcached_flush_buffers.c \
|
|
57
59
|
md5.c \
|
|
58
60
|
memcached_key.c \
|
|
59
61
|
memcached_quit.c \
|
|
@@ -69,7 +71,7 @@ libmemcached_la_SOURCES = crc.c \
|
|
|
69
71
|
memcached_version.c \
|
|
70
72
|
murmur_hash.c \
|
|
71
73
|
jenkins_hash.c \
|
|
72
|
-
|
|
74
|
+
memcached_allocators.c
|
|
73
75
|
|
|
74
76
|
|
|
75
77
|
if INCLUDE_HSIEH_SRC
|
|
@@ -109,7 +109,7 @@ LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
|
|
|
109
109
|
am__DEPENDENCIES_1 =
|
|
110
110
|
am__libmemcached_la_SOURCES_DIST = crc.c memcached.c memcached_auto.c \
|
|
111
111
|
memcached_analyze.c memcached_behavior.c memcached_connect.c \
|
|
112
|
-
memcached_delete.c memcached_do.c memcached_dump.c \
|
|
112
|
+
memcached_delete.c memcached_do.c memcached_dump.c memcached_exist.c \
|
|
113
113
|
memcached_fetch.c memcached_flush.c memcached_get.c \
|
|
114
114
|
memcached_touch.c memcached_hash.c memcached_hosts.c \
|
|
115
115
|
memcached_io.c memcached_purge.c memcached_flush_buffers.c \
|
|
@@ -132,6 +132,7 @@ am_libmemcached_la_OBJECTS = libmemcached_la-crc.lo \
|
|
|
132
132
|
libmemcached_la-memcached_delete.lo \
|
|
133
133
|
libmemcached_la-memcached_do.lo \
|
|
134
134
|
libmemcached_la-memcached_dump.lo \
|
|
135
|
+
libmemcached_la-memcached_exist.lo \
|
|
135
136
|
libmemcached_la-memcached_fetch.lo \
|
|
136
137
|
libmemcached_la-memcached_flush.lo \
|
|
137
138
|
libmemcached_la-memcached_get.lo \
|
|
@@ -169,7 +170,7 @@ libmemcachedcallbacks_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
|
|
169
170
|
$(LIBTOOLFLAGS) --mode=link $(CCLD) \
|
|
170
171
|
$(libmemcachedcallbacks_la_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
|
171
172
|
$(LDFLAGS) -o $@
|
|
172
|
-
DEFAULT_INCLUDES =
|
|
173
|
+
DEFAULT_INCLUDES =
|
|
173
174
|
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
|
|
174
175
|
am__depfiles_maybe = depfiles
|
|
175
176
|
am__mv = mv -f
|
|
@@ -191,7 +192,7 @@ am__pkginclude_HEADERS_DIST = memcached.h memcached.hpp \
|
|
|
191
192
|
memcached_result.h memcached_sasl.h memcached_server.h \
|
|
192
193
|
memcached_storage.h memcached_string.h memcached_touch.h \
|
|
193
194
|
memcached_types.h memcached_watchpoint.h visibility.h \
|
|
194
|
-
memcached_util.h memcached_pool.h
|
|
195
|
+
memcached_util.h memcached_pool.h memcached_exist.h
|
|
195
196
|
HEADERS = $(noinst_HEADERS) $(pkginclude_HEADERS)
|
|
196
197
|
ETAGS = etags
|
|
197
198
|
CTAGS = ctags
|
|
@@ -362,7 +363,7 @@ top_srcdir = @top_srcdir@
|
|
|
362
363
|
EXTRA_DIST = libmemcached_probes.d memcached/README.txt libmemcached.ver \
|
|
363
364
|
memcached_configure.h.in
|
|
364
365
|
|
|
365
|
-
EXTRA_HEADERS =
|
|
366
|
+
EXTRA_HEADERS =
|
|
366
367
|
BUILT_SOURCES = $(am__append_6)
|
|
367
368
|
noinst_HEADERS = libmemcached_probes.h \
|
|
368
369
|
memcached_io.h \
|
|
@@ -371,7 +372,7 @@ noinst_HEADERS = libmemcached_probes.h \
|
|
|
371
372
|
memcached/protocol_binary.h
|
|
372
373
|
|
|
373
374
|
pkginclude_HEADERS = memcached.h memcached.hpp memcached_configure.h \
|
|
374
|
-
memcached_constants.h memcached_get.h memcached_result.h \
|
|
375
|
+
memcached_constants.h memcached_get.h memcached_exist.h memcached_result.h \
|
|
375
376
|
memcached_sasl.h memcached_server.h memcached_storage.h \
|
|
376
377
|
memcached_string.h memcached_touch.h memcached_types.h \
|
|
377
378
|
memcached_watchpoint.h visibility.h $(am__append_1)
|
|
@@ -383,7 +384,7 @@ libmemcached_la_CFLAGS = ${AM_CFLAGS} ${NO_CONVERSION}
|
|
|
383
384
|
libmemcached_la_SOURCES = crc.c memcached.c memcached_auto.c \
|
|
384
385
|
memcached_analyze.c memcached_behavior.c memcached_connect.c \
|
|
385
386
|
memcached_delete.c memcached_do.c memcached_dump.c \
|
|
386
|
-
memcached_fetch.c memcached_flush.c memcached_get.c \
|
|
387
|
+
memcached_exist.c memcached_fetch.c memcached_flush.c memcached_get.c \
|
|
387
388
|
memcached_touch.c memcached_hash.c memcached_hosts.c \
|
|
388
389
|
memcached_io.c memcached_purge.c memcached_flush_buffers.c \
|
|
389
390
|
md5.c memcached_key.c memcached_quit.c memcached_parse.c \
|
|
@@ -476,9 +477,9 @@ clean-noinstLTLIBRARIES:
|
|
|
476
477
|
echo "rm -f \"$${dir}/so_locations\""; \
|
|
477
478
|
rm -f "$${dir}/so_locations"; \
|
|
478
479
|
done
|
|
479
|
-
libmemcached.la: $(libmemcached_la_OBJECTS) $(libmemcached_la_DEPENDENCIES)
|
|
480
|
+
libmemcached.la: $(libmemcached_la_OBJECTS) $(libmemcached_la_DEPENDENCIES)
|
|
480
481
|
$(libmemcached_la_LINK) -rpath $(libdir) $(libmemcached_la_OBJECTS) $(libmemcached_la_LIBADD) $(LIBS)
|
|
481
|
-
libmemcachedcallbacks.la: $(libmemcachedcallbacks_la_OBJECTS) $(libmemcachedcallbacks_la_DEPENDENCIES)
|
|
482
|
+
libmemcachedcallbacks.la: $(libmemcachedcallbacks_la_OBJECTS) $(libmemcachedcallbacks_la_DEPENDENCIES)
|
|
482
483
|
$(libmemcachedcallbacks_la_LINK) $(libmemcachedcallbacks_la_OBJECTS) $(libmemcachedcallbacks_la_LIBADD) $(LIBS)
|
|
483
484
|
|
|
484
485
|
mostlyclean-compile:
|
|
@@ -613,6 +614,13 @@ libmemcached_la-memcached_dump.lo: memcached_dump.c
|
|
|
613
614
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
614
615
|
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmemcached_la_CFLAGS) $(CFLAGS) -c -o libmemcached_la-memcached_dump.lo `test -f 'memcached_dump.c' || echo '$(srcdir)/'`memcached_dump.c
|
|
615
616
|
|
|
617
|
+
libmemcached_la-memcached_exist.lo: memcached_exist.c
|
|
618
|
+
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmemcached_la_CFLAGS) $(CFLAGS) -MT libmemcached_la-memcached_exist.lo -MD -MP -MF $(DEPDIR)/libmemcached_la-memcached_exist.Tpo -c -o libmemcached_la-memcached_exist.lo `test -f 'memcached_exist.c' || echo '$(srcdir)/'`memcached_exist.c
|
|
619
|
+
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libmemcached_la-memcached_exist.Tpo $(DEPDIR)/libmemcached_la-memcached_exist.Plo
|
|
620
|
+
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='memcached_exist.c' object='libmemcached_la-memcached_exist.lo' libtool=yes @AMDEPBACKSLASH@
|
|
621
|
+
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
|
622
|
+
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmemcached_la_CFLAGS) $(CFLAGS) -c -o libmemcached_la-memcached_exist.lo `test -f 'memcached_exist.c' || echo '$(srcdir)/'`memcached_exist.c
|
|
623
|
+
|
|
616
624
|
libmemcached_la-memcached_fetch.lo: memcached_fetch.c
|
|
617
625
|
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmemcached_la_CFLAGS) $(CFLAGS) -MT libmemcached_la-memcached_fetch.lo -MD -MP -MF $(DEPDIR)/libmemcached_la-memcached_fetch.Tpo -c -o libmemcached_la-memcached_fetch.lo `test -f 'memcached_fetch.c' || echo '$(srcdir)/'`memcached_fetch.c
|
|
618
626
|
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libmemcached_la-memcached_fetch.Tpo $(DEPDIR)/libmemcached_la-memcached_fetch.Plo
|
|
@@ -136,6 +136,12 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death);
|
|
|
136
136
|
LIBMEMCACHED_LOCAL
|
|
137
137
|
memcached_return memcached_do(memcached_server_st *ptr, const void *commmand,
|
|
138
138
|
size_t command_length, uint8_t with_flush);
|
|
139
|
+
|
|
140
|
+
LIBMEMCACHED_LOCAL
|
|
141
|
+
memcached_return memcached_vdo(memcached_server_st *ptr,
|
|
142
|
+
const struct libmemcached_io_vector_st *vector, size_t count,
|
|
143
|
+
uint8_t with_flush);
|
|
144
|
+
|
|
139
145
|
LIBMEMCACHED_LOCAL
|
|
140
146
|
memcached_return value_fetch(memcached_server_st *ptr,
|
|
141
147
|
char *buffer,
|
|
@@ -161,11 +167,11 @@ extern uint64_t htonll(uint64_t);
|
|
|
161
167
|
LIBMEMCACHED_LOCAL
|
|
162
168
|
memcached_return memcached_purge(memcached_server_st *ptr);
|
|
163
169
|
|
|
164
|
-
static inline memcached_return memcached_validate_key_length(size_t key_length,
|
|
170
|
+
static inline memcached_return memcached_validate_key_length(size_t key_length,
|
|
165
171
|
bool binary) {
|
|
166
172
|
unlikely (key_length == 0)
|
|
167
173
|
return MEMCACHED_BAD_KEY_PROVIDED;
|
|
168
|
-
|
|
174
|
+
|
|
169
175
|
if (binary)
|
|
170
176
|
{
|
|
171
177
|
unlikely (key_length > 0xffff)
|
|
@@ -173,7 +179,7 @@ static inline memcached_return memcached_validate_key_length(size_t key_length,
|
|
|
173
179
|
}
|
|
174
180
|
else
|
|
175
181
|
{
|
|
176
|
-
unlikely (key_length >= MEMCACHED_MAX_KEY)
|
|
182
|
+
unlikely (key_length >= MEMCACHED_MAX_KEY)
|
|
177
183
|
return MEMCACHED_BAD_KEY_PROVIDED;
|
|
178
184
|
}
|
|
179
185
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#include "common.h"
|
|
2
2
|
|
|
3
|
-
memcached_return memcached_do(memcached_server_st *ptr, const void *command,
|
|
3
|
+
memcached_return memcached_do(memcached_server_st *ptr, const void *command,
|
|
4
4
|
size_t command_length, uint8_t with_flush)
|
|
5
5
|
{
|
|
6
6
|
memcached_return rc;
|
|
@@ -32,3 +32,39 @@ memcached_return memcached_do(memcached_server_st *ptr, const void *command,
|
|
|
32
32
|
|
|
33
33
|
return rc;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
memcached_return memcached_vdo(memcached_server_st *ptr,
|
|
37
|
+
const struct libmemcached_io_vector_st *vector, size_t count,
|
|
38
|
+
uint8_t with_flush)
|
|
39
|
+
{
|
|
40
|
+
memcached_return rc;
|
|
41
|
+
ssize_t sent_length;
|
|
42
|
+
|
|
43
|
+
WATCHPOINT_ASSERT(count);
|
|
44
|
+
WATCHPOINT_ASSERT(vector);
|
|
45
|
+
|
|
46
|
+
if ((rc= memcached_connect(ptr)) != MEMCACHED_SUCCESS)
|
|
47
|
+
{
|
|
48
|
+
WATCHPOINT_ERROR(rc);
|
|
49
|
+
return rc;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (ptr->type == MEMCACHED_CONNECTION_UDP && with_flush && ptr->write_buffer_offset > UDP_DATAGRAM_HEADER_LENGTH)
|
|
53
|
+
{
|
|
54
|
+
memcached_io_write(ptr, NULL, 0, true);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
sent_length= memcached_io_writev(ptr, vector, count, (char) with_flush);
|
|
58
|
+
|
|
59
|
+
size_t command_length = 0;
|
|
60
|
+
for (uint32_t x= 0; x < count; ++x, vector++)
|
|
61
|
+
command_length+= vector->length;
|
|
62
|
+
|
|
63
|
+
if (sent_length == -1 || (size_t)sent_length != command_length) {
|
|
64
|
+
rc = MEMCACHED_WRITE_FAILURE;
|
|
65
|
+
WATCHPOINT_ERROR(rc);
|
|
66
|
+
} else if ((ptr->root->flags & MEM_NOREPLY) == 0)
|
|
67
|
+
memcached_server_response_increment(ptr);
|
|
68
|
+
|
|
69
|
+
return rc;
|
|
70
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#include <libmemcached/common.h>
|
|
2
|
+
|
|
3
|
+
static memcached_return binary_exist(memcached_st *ptr, memcached_server_st *server,
|
|
4
|
+
const char* key, size_t key_length)
|
|
5
|
+
{
|
|
6
|
+
protocol_binary_request_set request= {.bytes= {0}};
|
|
7
|
+
size_t send_length= sizeof(request.bytes);
|
|
8
|
+
|
|
9
|
+
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
|
10
|
+
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_ADD;
|
|
11
|
+
request.message.header.request.keylen= htons((uint16_t)(ptr->prefix_key_length + key_length));
|
|
12
|
+
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
|
13
|
+
request.message.header.request.extlen= 8;
|
|
14
|
+
request.message.body.flags= 0;
|
|
15
|
+
request.message.body.expiration= htonl(2678400);
|
|
16
|
+
|
|
17
|
+
request.message.header.request.bodylen= htonl((uint32_t) (key_length
|
|
18
|
+
+ptr->prefix_key_length
|
|
19
|
+
+request.message.header.request.extlen));
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
struct libmemcached_io_vector_st vector[]=
|
|
23
|
+
{
|
|
24
|
+
{ send_length, request.bytes },
|
|
25
|
+
{ strlen(ptr->prefix_key), ptr->prefix_key },
|
|
26
|
+
{ key_length, key }
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
memcached_return rc= memcached_vdo(server, vector, 3, 1);
|
|
30
|
+
if (rc != MEMCACHED_SUCCESS)
|
|
31
|
+
{
|
|
32
|
+
memcached_io_reset(server);
|
|
33
|
+
return (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
rc= memcached_response(server, NULL, 0, NULL);
|
|
37
|
+
|
|
38
|
+
if (rc == MEMCACHED_SUCCESS)
|
|
39
|
+
rc= MEMCACHED_NOTFOUND;
|
|
40
|
+
|
|
41
|
+
if (rc == MEMCACHED_DATA_EXISTS)
|
|
42
|
+
rc= MEMCACHED_SUCCESS;
|
|
43
|
+
|
|
44
|
+
return rc;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static memcached_return ascii_exist(memcached_st *ptr, memcached_server_st *server,
|
|
48
|
+
const char* key, size_t key_length)
|
|
49
|
+
{
|
|
50
|
+
struct libmemcached_io_vector_st vector[]=
|
|
51
|
+
{
|
|
52
|
+
{ sizeof("add ") -1, "add " },
|
|
53
|
+
{ strlen(ptr->prefix_key), ptr->prefix_key },
|
|
54
|
+
{ key_length, key },
|
|
55
|
+
{ sizeof(" 0") -1, " 0" },
|
|
56
|
+
{ sizeof(" 2678400") -1, " 2678400" },
|
|
57
|
+
{ sizeof(" 0") -1, " 0" },
|
|
58
|
+
{ 2, "\r\n" },
|
|
59
|
+
{ 2, "\r\n" }
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
memcached_return rc = memcached_vdo(server, vector, 8, 1);
|
|
63
|
+
|
|
64
|
+
if (rc == MEMCACHED_SUCCESS)
|
|
65
|
+
{
|
|
66
|
+
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
|
|
67
|
+
rc= memcached_response(server, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
|
|
68
|
+
|
|
69
|
+
if (rc == MEMCACHED_NOTSTORED)
|
|
70
|
+
rc= MEMCACHED_SUCCESS;
|
|
71
|
+
|
|
72
|
+
if (rc == MEMCACHED_STORED)
|
|
73
|
+
rc= MEMCACHED_NOTFOUND;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (rc == MEMCACHED_WRITE_FAILURE)
|
|
77
|
+
memcached_io_reset(server);
|
|
78
|
+
|
|
79
|
+
return rc;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
memcached_return memcached_exist(memcached_st *ptr, const char *key, size_t key_length)
|
|
83
|
+
{
|
|
84
|
+
return memcached_exist_by_key(ptr, key, key_length, key, key_length);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
memcached_return memcached_exist_by_key(memcached_st *ptr,
|
|
88
|
+
const char *group_key, size_t group_key_length,
|
|
89
|
+
const char *key, size_t key_length)
|
|
90
|
+
{
|
|
91
|
+
unlikely (ptr->flags & MEM_USE_UDP)
|
|
92
|
+
return MEMCACHED_NOT_SUPPORTED;
|
|
93
|
+
|
|
94
|
+
if (ptr->number_of_hosts == 0)
|
|
95
|
+
return MEMCACHED_NO_SERVERS;
|
|
96
|
+
|
|
97
|
+
if (ptr->flags & MEM_NOREPLY)
|
|
98
|
+
{
|
|
99
|
+
size_t dummy_length;
|
|
100
|
+
uint32_t dummy_flags;
|
|
101
|
+
memcached_return dummy_error;
|
|
102
|
+
|
|
103
|
+
memcached_get(ptr, key, key_length, &dummy_length, &dummy_flags, &dummy_error);
|
|
104
|
+
return dummy_error;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
unsigned int server_key= memcached_generate_hash(ptr, key, key_length);
|
|
108
|
+
memcached_server_st *server= &ptr->hosts[server_key];
|
|
109
|
+
|
|
110
|
+
if (ptr->flags & MEM_BINARY_PROTOCOL)
|
|
111
|
+
return binary_exist(ptr, server, key, key_length);
|
|
112
|
+
else
|
|
113
|
+
return ascii_exist(ptr, server, key, key_length);
|
|
114
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#ifndef __MEMCACHED_EXIST_H__
|
|
2
|
+
#define __MEMCACHED_EXIST_H__
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
LIBMEMCACHED_API
|
|
9
|
+
memcached_return memcached_exist(memcached_st *memc, const char *key, size_t key_length);
|
|
10
|
+
|
|
11
|
+
LIBMEMCACHED_API
|
|
12
|
+
memcached_return memcached_exist_by_key(memcached_st *memc,
|
|
13
|
+
const char *group_key, size_t group_key_length,
|
|
14
|
+
const char *key, size_t key_length);
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
}
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#endif /* __MEMCACHED_EXIST_H__ */
|
|
@@ -178,8 +178,8 @@ memcached_return memcached_io_read(memcached_server_st *ptr,
|
|
|
178
178
|
return MEMCACHED_SUCCESS;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
ssize_t
|
|
182
|
-
|
|
181
|
+
static ssize_t _io_write(memcached_server_st *ptr,
|
|
182
|
+
const void *buffer, size_t length, char with_flush)
|
|
183
183
|
{
|
|
184
184
|
size_t original_length;
|
|
185
185
|
const char* buffer_ptr;
|
|
@@ -245,6 +245,34 @@ ssize_t memcached_io_write(memcached_server_st *ptr,
|
|
|
245
245
|
return (ssize_t) original_length;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
ssize_t memcached_io_write(memcached_server_st *ptr,
|
|
249
|
+
const void *buffer, size_t length, char with_flush)
|
|
250
|
+
{
|
|
251
|
+
return _io_write(ptr, buffer, length, with_flush);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
ssize_t memcached_io_writev(memcached_server_st *ptr,
|
|
255
|
+
const struct libmemcached_io_vector_st *vector,
|
|
256
|
+
size_t number_of, char with_flush)
|
|
257
|
+
{
|
|
258
|
+
ssize_t total = 0;
|
|
259
|
+
char f = (char)false;
|
|
260
|
+
|
|
261
|
+
for (size_t x = 0; x < number_of; x++, vector++)
|
|
262
|
+
{
|
|
263
|
+
ssize_t returnable;
|
|
264
|
+
if ((returnable= _io_write(ptr, vector->buffer, vector->length, f)) == -1)
|
|
265
|
+
return -1;
|
|
266
|
+
|
|
267
|
+
total+= returnable;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (with_flush && _io_write(ptr, NULL, 0, (char)true) == -1)
|
|
271
|
+
return -1;
|
|
272
|
+
|
|
273
|
+
return total;
|
|
274
|
+
}
|
|
275
|
+
|
|
248
276
|
memcached_return memcached_io_close(memcached_server_st *ptr)
|
|
249
277
|
{
|
|
250
278
|
int r;
|
|
@@ -429,7 +457,7 @@ static ssize_t io_flush(memcached_server_st *ptr,
|
|
|
429
457
|
return (ssize_t) return_length;
|
|
430
458
|
}
|
|
431
459
|
|
|
432
|
-
/*
|
|
460
|
+
/*
|
|
433
461
|
Eventually we will just kill off the server with the problem.
|
|
434
462
|
*/
|
|
435
463
|
void memcached_io_reset(memcached_server_st *ptr)
|
|
@@ -439,7 +467,7 @@ void memcached_io_reset(memcached_server_st *ptr)
|
|
|
439
467
|
|
|
440
468
|
/**
|
|
441
469
|
* Read a given number of bytes from the server and place it into a specific
|
|
442
|
-
* buffer. Reset the IO channel on this server if an error occurs.
|
|
470
|
+
* buffer. Reset the IO channel on this server if an error occurs.
|
|
443
471
|
*/
|
|
444
472
|
memcached_return memcached_safe_read(memcached_server_st *ptr,
|
|
445
473
|
void *dta,
|
|
@@ -526,7 +554,7 @@ static void increment_udp_message_id(memcached_server_st *ptr)
|
|
|
526
554
|
uint16_t cur_req= get_udp_datagram_request_id(header);
|
|
527
555
|
int msg_num= get_msg_num_from_request_id(cur_req);
|
|
528
556
|
int thread_id= get_thread_id_from_request_id(cur_req);
|
|
529
|
-
|
|
557
|
+
|
|
530
558
|
if (((++msg_num) & UDP_REQUEST_ID_THREAD_MASK) != 0)
|
|
531
559
|
msg_num= 0;
|
|
532
560
|
|
|
@@ -32,8 +32,21 @@ struct udp_datagram_header_st {
|
|
|
32
32
|
uint16_t reserved;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
struct libmemcached_io_vector_st
|
|
36
|
+
{
|
|
37
|
+
size_t length;
|
|
38
|
+
const void *buffer;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
LIBMEMCACHED_LOCAL
|
|
35
42
|
ssize_t memcached_io_write(memcached_server_st *ptr,
|
|
36
43
|
const void *buffer, size_t length, char with_flush);
|
|
44
|
+
|
|
45
|
+
LIBMEMCACHED_LOCAL
|
|
46
|
+
ssize_t memcached_io_writev(memcached_server_st *ptr,
|
|
47
|
+
const struct libmemcached_io_vector_st *vector,
|
|
48
|
+
size_t number_of, char with_flush);
|
|
49
|
+
|
|
37
50
|
void memcached_io_reset(memcached_server_st *ptr);
|
|
38
51
|
memcached_return memcached_io_read(memcached_server_st *ptr,
|
|
39
52
|
void *buffer, size_t length, ssize_t *nread);
|
|
@@ -43,8 +56,8 @@ memcached_return memcached_io_readline(memcached_server_st *ptr,
|
|
|
43
56
|
size_t size);
|
|
44
57
|
memcached_return memcached_io_close(memcached_server_st *ptr);
|
|
45
58
|
/* Read n bytes of data from the server and store them in dta */
|
|
46
|
-
memcached_return memcached_safe_read(memcached_server_st *ptr,
|
|
47
|
-
void *dta,
|
|
59
|
+
memcached_return memcached_safe_read(memcached_server_st *ptr,
|
|
60
|
+
void *dta,
|
|
48
61
|
size_t size);
|
|
49
62
|
/* Read a single response from the server */
|
|
50
63
|
memcached_return memcached_read_one_response(memcached_server_st *ptr,
|