@@ -39,6 +39,47 @@ static void auto_response(memcached_instance_st *instance, const bool reply, mem
39
39
}
40
40
}
41
41
42
+ static memcached_return_t meta_incr_decr (memcached_instance_st *instance, bool is_incr, bool w_init,
43
+ const char *key, size_t key_len,
44
+ uint64_t offset, uint64_t initial, uint32_t expiration) {
45
+ char new_buf[32 ] = " N" , inl_buf[32 ] = " J" , dlt_buf[32 ] = " D" , exp_buf[32 ] = " T" ;
46
+ size_t new_len = strlen (new_buf), inl_len = strlen (inl_buf), dlt_len = strlen (dlt_buf), exp_len = strlen (exp_buf);
47
+ size_t io_num = 0 ;
48
+ libmemcached_io_vector_st io_vec[10 ] = {};
49
+
50
+ io_vec[io_num++] = {memcached_literal_param (" ma " )};
51
+ io_vec[io_num++] = {memcached_array_string (instance->root ->_namespace ),
52
+ memcached_array_size (instance->root ->_namespace )},
53
+ io_vec[io_num++] = {key, key_len};
54
+
55
+ if (!is_incr) {
56
+ io_vec[io_num++] = {memcached_literal_param (" MD" )};
57
+ }
58
+ if (w_init) {
59
+ new_len += snprintf (new_buf + new_len, sizeof (new_buf) - new_len, " %" PRIu32, expiration);
60
+ io_vec[io_num++] = {new_buf, new_len};
61
+ inl_len += snprintf (inl_buf + inl_len, sizeof (inl_buf) - inl_len, " %" PRIu64, initial);
62
+ io_vec[io_num++] = {inl_buf, inl_len};
63
+ }
64
+ if (offset != 1 ) {
65
+ dlt_len += snprintf (dlt_buf + dlt_len, sizeof (dlt_buf) - dlt_len, " %" PRIu64, offset);
66
+ io_vec[io_num++] = {dlt_buf, dlt_len};
67
+ }
68
+ if (expiration) {
69
+ exp_len += snprintf (exp_buf + exp_len, sizeof (exp_buf) - exp_len, " %" PRIu32, expiration);
70
+ io_vec[io_num++] = {exp_buf, exp_len};
71
+ }
72
+
73
+ if (memcached_is_replying (instance->root )) {
74
+ io_vec[io_num++] = {memcached_literal_param (" v" )};
75
+ } else {
76
+ io_vec[io_num++] = {memcached_literal_param (" q" )};
77
+ }
78
+ io_vec[io_num++] = {memcached_literal_param (" O+\r\n " )};
79
+
80
+ return memcached_vdo (instance, io_vec, io_num, true );
81
+ }
82
+
42
83
static memcached_return_t text_incr_decr (memcached_instance_st *instance, const bool is_incr,
43
84
const char *key, size_t key_length, const uint64_t offset,
44
85
const bool reply) {
@@ -145,6 +186,8 @@ static memcached_return_t increment_decrement_by_key(const protocol_binary_comma
145
186
if (memcached_is_binary (memc)) {
146
187
rc = binary_incr_decr (instance, command, key, key_length, uint64_t (offset), 0 ,
147
188
MEMCACHED_EXPIRATION_NOT_ADD, reply);
189
+ } else if (memcached_is_meta (memc)) {
190
+ rc = meta_incr_decr (instance, command == PROTOCOL_BINARY_CMD_INCREMENT, false , key, key_length, offset, 0 , 0 );
148
191
} else {
149
192
rc = text_incr_decr (instance, command == PROTOCOL_BINARY_CMD_INCREMENT ? true : false , key,
150
193
key_length, offset, reply);
@@ -189,7 +232,9 @@ increment_decrement_with_initial_by_key(const protocol_binary_command command, M
189
232
if (memcached_is_binary (memc)) {
190
233
rc = binary_incr_decr (instance, command, key, key_length, offset, initial, uint32_t (expiration),
191
234
reply);
192
-
235
+ } else if (memcached_is_meta (memc)) {
236
+ rc = meta_incr_decr (instance, command == PROTOCOL_BINARY_CMD_INCREMENT, true ,
237
+ key, key_length, offset, initial, uint32_t (expiration));
193
238
} else {
194
239
rc = memcached_set_error (
195
240
*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
0 commit comments