Oracle 5.0 Reference Manual page 1385

Table of Contents

Advertisement

The main get-style function, which is equivalent to the generic
function returns a string pointer, pointing to the value associated with the specified key.
char *memcached_get (memcached_st *ptr,
const char *key, size_t key_length,
size_t *value_length,
uint32_t *flags,
memcached_return *error);
A multi-key get, memcached_mget(), is also available. Using a multiple key get operation is much
quicker to do in one block than retrieving the key values with individual calls to memcached_get(). To
start the multi-key get, call memcached_mget():
memcached_return
memcached_mget (memcached_st *ptr,
char **keys, size_t *key_length,
unsigned int number_of_keys);
The return value is the success of the operation. The
containing the keys, and
is the number of keys supplied in the array.
number_of_keys
To fetch the individual values, use
char *memcached_fetch (memcached_st *ptr,
The function returns the key value, with the key,
populated with the corresponding key and length information. The function returns
are no more values to be returned. A full example, including the populating of the key data and the
return of the information is provided here.
#include <stdio.h>
#include <sstring.h>
#include <unistd.h>
#include <libmemcached/memcached.h>
int main(int argc, char *argv[])
{
memcached_server_st *servers = NULL;
memcached_st *memc;
memcached_return rc;
char *keys[]= {"huey", "dewey", "louie"};
size_t key_length[3];
char *values[]= {"red", "blue", "green"};
size_t value_length[3];
unsigned int x;
uint32_t flags;
char return_key[MEMCACHED_MAX_KEY];
size_t return_key_length;
char *return_value;
size_t return_value_length;
memc= memcached_create(NULL);
servers= memcached_server_list_append(servers, "localhost", 11211, &rc);
rc= memcached_server_push(memc, servers);
if (rc == MEMCACHED_SUCCESS)
fprintf(stderr,"Added server successfully\n");
else
fprintf(stderr,"Couldn't add server: %s\n",memcached_strerror(memc, rc));
for(x= 0; x < 3; x++)
{
key_length[x] = strlen(keys[x]);
Developing a
memcached
an array containing the length of each corresponding key.
key_length
memcached_fetch()
const char *key, size_t *key_length,
size_t *value_length,
uint32_t *flags,
memcached_return *error);
1365
Application
is memcached_get(). This
get()
parameter should be an array of strings
keys
to get each corresponding value.
and
key_length
value_length
parameters being
when there
NULL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents