2 Execute a memcached_set() a set of pairs.
3 Return the number of rows set.
6 #include "libmemcached/common.h"
10 unsigned int execute_set(memcached_st
*memc
, pairs_st
*pairs
, unsigned int number_of
)
14 unsigned int pairs_sent
;
16 for (x
= 0, pairs_sent
= 0; x
< number_of
; x
++)
18 rc
= memcached_set(memc
, pairs
[x
].key
, pairs
[x
].key_length
,
19 pairs
[x
].value
, pairs
[x
].value_length
,
21 if (rc
!= MEMCACHED_SUCCESS
&& rc
!= MEMCACHED_BUFFERED
)
22 fprintf(stderr
, "Failured on insert of %.*s\n",
23 (unsigned int)pairs
[x
].key_length
, pairs
[x
].key
);
32 Execute a memcached_get() on a set of pairs.
33 Return the number of rows retrieved.
35 unsigned int execute_get(memcached_st
*memc
, pairs_st
*pairs
, unsigned int number_of
)
39 unsigned int retrieved
;
42 for (retrieved
= 0,x
= 0; x
< number_of
; x
++)
47 unsigned int fetch_key
;
49 fetch_key
= (unsigned int)((unsigned int)random() % number_of
);
51 value
= memcached_get(memc
, pairs
[fetch_key
].key
, pairs
[fetch_key
].key_length
,
52 &value_length
, &flags
, &rc
);
54 if (rc
!= MEMCACHED_SUCCESS
)
55 fprintf(stderr
, "Failured on read of %.*s\n",
56 (unsigned int)pairs
[fetch_key
].key_length
, pairs
[fetch_key
].key
);