libyrmcds
memcached/yrmcds client library for C
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
yrmcds.h File Reference

libyrmcds public API. More...

#include <pthread.h>
#include <stddef.h>
#include <stdint.h>

Data Structures

struct  yrmcds
 Data structure of a connection to memcached/yrmcds server. More...
 
struct  yrmcds_response
 Data structure to store a response packet. More...
 
struct  yrmcds_cnt_stat
 Data structure to store the reference to a statistic data for the counter extension. More...
 
struct  yrmcds_cnt_statistics
 Data structure to store statistics for the counter extension. More...
 
struct  yrmcds_cnt
 Data structure of a connection to yrmcds counter server. More...
 
struct  yrmcds_cnt_response
 Data structure to store a response packet for the counter extension. More...
 

Macros

#define YRMCDS_H_INCLUDED
 
#define LIBYRMCDS_VERSION   "1.3.0"
 Library version string such as "1.3.0".
 
#define LIBYRMCDS_VERSION_NUMBER   10300
 Library version number such as 10201.
 

Enumerations

enum  yrmcds_status {
  YRMCDS_STATUS_OK = 0, YRMCDS_STATUS_NOTFOUND = 0x0001, YRMCDS_STATUS_EXISTS = 0x0002, YRMCDS_STATUS_TOOLARGEVALUE = 0x0003,
  YRMCDS_STATUS_INVALID = 0x0004, YRMCDS_STATUS_NOTSTORED = 0x0005, YRMCDS_STATUS_NONNUMERIC = 0x0006, YRMCDS_STATUS_LOCKED = 0x0010,
  YRMCDS_STATUS_NOTLOCKED = 0x0011, YRMCDS_STATUS_UNKNOWNCOMMAND = 0x0081, YRMCDS_STATUS_OUTOFMEMORY = 0x0082, YRMCDS_STATUS_OTHER = 0xffff
}
 Server status codes. More...
 
enum  yrmcds_command {
  YRMCDS_CMD_GET = '\x00', YRMCDS_CMD_SET = '\x01', YRMCDS_CMD_ADD = '\x02', YRMCDS_CMD_REPLACE = '\x03',
  YRMCDS_CMD_DELETE = '\x04', YRMCDS_CMD_INCREMENT = '\x05', YRMCDS_CMD_DECREMENT = '\x06', YRMCDS_CMD_QUIT = '\x07',
  YRMCDS_CMD_FLUSH = '\x08', YRMCDS_CMD_GETQ = '\x09', YRMCDS_CMD_NOOP = '\x0a', YRMCDS_CMD_VERSION = '\x0b',
  YRMCDS_CMD_GETK = '\x0c', YRMCDS_CMD_GETKQ = '\x0d', YRMCDS_CMD_APPEND = '\x0e', YRMCDS_CMD_PREPEND = '\x0f',
  YRMCDS_CMD_STAT = '\x10', YRMCDS_CMD_SETQ = '\x11', YRMCDS_CMD_ADDQ = '\x12', YRMCDS_CMD_REPLACEQ = '\x13',
  YRMCDS_CMD_DELETEQ = '\x14', YRMCDS_CMD_INCREMENTQ = '\x15', YRMCDS_CMD_DECREMENTQ = '\x16', YRMCDS_CMD_QUITQ = '\x17',
  YRMCDS_CMD_FLUSHQ = '\x18', YRMCDS_CMD_APPENDQ = '\x19', YRMCDS_CMD_PREPENDQ = '\x1a', YRMCDS_CMD_TOUCH = '\x1c',
  YRMCDS_CMD_GAT = '\x1d', YRMCDS_CMD_GATQ = '\x1e', YRMCDS_CMD_GATK = '\x23', YRMCDS_CMD_GATKQ = '\x24',
  YRMCDS_CMD_LOCK = '\x40', YRMCDS_CMD_LOCKQ = '\x41', YRMCDS_CMD_UNLOCK = '\x42', YRMCDS_CMD_UNLOCKQ = '\x43',
  YRMCDS_CMD_UNLOCKALL = '\x44', YRMCDS_CMD_UNLOCKALLQ = '\x45', YRMCDS_CMD_LAG = '\x46', YRMCDS_CMD_LAGQ = '\x47',
  YRMCDS_CMD_LAGK = '\x48', YRMCDS_CMD_LAGKQ = '\x49', YRMCDS_CMD_RAU = '\x4a', YRMCDS_CMD_RAUQ = '\x4b',
  YRMCDS_CMD_KEYS = '\x50', YRMCDS_CMD_BOTTOM
}
 Binary commands.
 
enum  yrmcds_error {
  YRMCDS_OK = 0, YRMCDS_SYSTEM_ERROR, YRMCDS_BAD_ARGUMENT, YRMCDS_NOT_RESOLVED,
  YRMCDS_TIMEOUT, YRMCDS_DISCONNECTED, YRMCDS_OUT_OF_MEMORY, YRMCDS_COMPRESS_FAILED,
  YRMCDS_PROTOCOL_ERROR, YRMCDS_NOT_IMPLEMENTED, YRMCDS_IN_BINARY, YRMCDS_BAD_KEY
}
 Library error numbers. More...
 
enum  yrmcds_flags { YRMCDS_FLAG_COMPRESS = 1 << 30 }
 Reserved flag bits. More...
 
enum  yrmcds_cnt_status {
  YRMCDS_CNT_STATUS_OK = 0x00, YRMCDS_CNT_STATUS_NOT_FOUND = 0x01, YRMCDS_CNT_STATUS_INVALID = 0x04, YRMCDS_CNT_STATUS_RESOURCE_NOT_AVAILABLE = 0x21,
  YRMCDS_CNT_STATUS_NOT_ACQUIRED = 0x22, YRMCDS_CNT_STATUS_UNKNOWN_COMMAND = 0x81, YRMCDS_CNT_STATUS_OUT_OF_MEMORY = 0x82
}
 Server status codes for the counter extension.
 
enum  yrmcds_cnt_command {
  YRMCDS_CNT_CMD_NOOP = 0x00, YRMCDS_CNT_CMD_GET = 0x01, YRMCDS_CNT_CMD_ACQUIRE = 0x02, YRMCDS_CNT_CMD_RELEASE = 0x03,
  YRMCDS_CNT_CMD_STATS = 0x10, YRMCDS_CNT_CMD_DUMP = 0x11
}
 Binary commands for the counter extension.
 

Functions

const char * yrmcds_strerror (yrmcds_error e)
 Return a string to describe a library error. More...
 
yrmcds_error yrmcds_connect (yrmcds *c, const char *node, uint16_t port)
 Connecct to a memcached/yrmcds server. More...
 
yrmcds_error yrmcds_close (yrmcds *c)
 Close the connection. More...
 
yrmcds_error yrmcds_shutdown (yrmcds *c)
 Shutdown the receiving end of the socket. More...
 
yrmcds_error yrmcds_text_mode (yrmcds *c)
 Turn on text protocol mode. More...
 
yrmcds_error yrmcds_set_compression (yrmcds *c, size_t threshold)
 Enable/disable (de)compression for large objects. More...
 
int yrmcds_fileno (yrmcds *c)
 Return the underlying socket in yrmcds. More...
 
yrmcds_error yrmcds_set_timeout (yrmcds *c, int timeout)
 Set timeout seconds for send/recv operations. More...
 
yrmcds_error yrmcds_recv (yrmcds *c, yrmcds_response *r)
 Receives a response packet. More...
 
yrmcds_error yrmcds_noop (yrmcds *c, uint32_t *serial)
 Send Noop command. More...
 
yrmcds_error yrmcds_get (yrmcds *c, const char *key, size_t key_len, int quiet, uint32_t *serial)
 Send Get/GetQ command. More...
 
yrmcds_error yrmcds_getk (yrmcds *c, const char *key, size_t key_len, int quiet, uint32_t *serial)
 Send GetK/GetKQ command. More...
 
yrmcds_error yrmcds_get_touch (yrmcds *c, const char *key, size_t key_len, uint32_t expire, int quiet, uint32_t *serial)
 Send GaT/GaTQ command. More...
 
yrmcds_error yrmcds_getk_touch (yrmcds *c, const char *key, size_t key_len, uint32_t expire, int quiet, uint32_t *serial)
 Send GaTK/GaTKQ command. More...
 
yrmcds_error yrmcds_lock_get (yrmcds *c, const char *key, size_t key_len, int quiet, uint32_t *serial)
 Send LaG/LaGQ command. More...
 
yrmcds_error yrmcds_lock_getk (yrmcds *c, const char *key, size_t key_len, int quiet, uint32_t *serial)
 Send LaGK/LaGKQ command. More...
 
yrmcds_error yrmcds_touch (yrmcds *c, const char *key, size_t key_len, uint32_t expire, int quiet, uint32_t *serial)
 Send Touch command. More...
 
yrmcds_error yrmcds_set (yrmcds *c, const char *key, size_t key_len, const char *data, size_t data_len, uint32_t flags, uint32_t expire, uint64_t cas, int quiet, uint32_t *serial)
 Send Set/SetQ command. More...
 
yrmcds_error yrmcds_replace (yrmcds *c, const char *key, size_t key_len, const char *data, size_t data_len, uint32_t flags, uint32_t expire, uint64_t cas, int quiet, uint32_t *serial)
 Send Replace/ReplaceQ command. More...
 
yrmcds_error yrmcds_add (yrmcds *c, const char *key, size_t key_len, const char *data, size_t data_len, uint32_t flags, uint32_t expire, uint64_t cas, int quiet, uint32_t *serial)
 Send Add/AddQ command. More...
 
yrmcds_error yrmcds_replace_unlock (yrmcds *c, const char *key, size_t key_len, const char *data, size_t data_len, uint32_t flags, uint32_t expire, int quiet, uint32_t *serial)
 Send RaU/RaUQ command. More...
 
yrmcds_error yrmcds_incr (yrmcds *c, const char *key, size_t key_len, uint64_t value, int quiet, uint32_t *serial)
 Send Increment/IncrementQ command. More...
 
yrmcds_error yrmcds_incr2 (yrmcds *c, const char *key, size_t key_len, uint64_t value, uint64_t initial, uint32_t expire, int quiet, uint32_t *serial)
 Send Increment/IncrementQ command. More...
 
yrmcds_error yrmcds_decr (yrmcds *c, const char *key, size_t key_len, uint64_t value, int quiet, uint32_t *serial)
 Send Decrement/DecrementQ command. More...
 
yrmcds_error yrmcds_decr2 (yrmcds *c, const char *key, size_t key_len, uint64_t value, uint64_t initial, uint32_t expire, int quiet, uint32_t *serial)
 Send Decrement/DecrementQ command. More...
 
yrmcds_error yrmcds_append (yrmcds *c, const char *key, size_t key_len, const char *data, size_t data_len, int quiet, uint32_t *serial)
 Send Append/AppendQ command. More...
 
yrmcds_error yrmcds_prepend (yrmcds *c, const char *key, size_t key_len, const char *data, size_t data_len, int quiet, uint32_t *serial)
 Send Prepend/PrependQ command. More...
 
yrmcds_error yrmcds_remove (yrmcds *c, const char *key, size_t key_len, int quiet, uint32_t *serial)
 Send Delete/DeleteQ command. More...
 
yrmcds_error yrmcds_lock (yrmcds *c, const char *key, size_t key_len, int quiet, uint32_t *serial)
 Send Lock/LockQ command. More...
 
yrmcds_error yrmcds_unlock (yrmcds *c, const char *key, size_t key_len, int quiet, uint32_t *serial)
 Send Unlock/UnlockQ command. More...
 
yrmcds_error yrmcds_unlockall (yrmcds *c, int quiet, uint32_t *serial)
 Send UnlockAll/UnlockAllQ command. More...
 
yrmcds_error yrmcds_flush (yrmcds *c, uint32_t delay, int quiet, uint32_t *serial)
 Send Flush/FlushQ command. More...
 
yrmcds_error yrmcds_stat_general (yrmcds *c, uint32_t *serial)
 Send Stat command to obtain general statistics. More...
 
yrmcds_error yrmcds_stat_settings (yrmcds *c, uint32_t *serial)
 Send Stat command to obtain setting statistics. More...
 
yrmcds_error yrmcds_stat_items (yrmcds *c, uint32_t *serial)
 Send Stat command to obtain item statistics. More...
 
yrmcds_error yrmcds_stat_sizes (yrmcds *c, uint32_t *serial)
 Send Stat command to obtain size statistics. More...
 
yrmcds_error yrmcds_keys (yrmcds *c, const char *prefix, size_t prefix_len, uint32_t *serial)
 Send Keys command to list all keys matching the given prefix. More...
 
yrmcds_error yrmcds_version (yrmcds *c, uint32_t *serial)
 Send Version command. More...
 
yrmcds_error yrmcds_quit (yrmcds *c, int quiet, uint32_t *serial)
 Send Quit/QuitQ command. More...
 
yrmcds_error yrmcds_cnt_connect (yrmcds_cnt *c, const char *node, uint16_t port)
 Connecct to a yrmcds server. More...
 
yrmcds_error yrmcds_cnt_close (yrmcds_cnt *c)
 Close the connection. More...
 
yrmcds_error yrmcds_cnt_shutdown (yrmcds_cnt *c)
 Shutdown the receiving end of the socket. More...
 
int yrmcds_cnt_fileno (yrmcds_cnt *c)
 Return the underlying socket in yrmcds_cnt. More...
 
yrmcds_error yrmcds_cnt_set_timeout (yrmcds_cnt *c, int timeout)
 Set timeout seconds for send/recv operations. More...
 
yrmcds_error yrmcds_cnt_recv (yrmcds_cnt *c, yrmcds_cnt_response *r)
 Receives a response packet. More...
 
yrmcds_error yrmcds_cnt_noop (yrmcds_cnt *c, uint32_t *serial)
 Send Noop command. More...
 
yrmcds_error yrmcds_cnt_get (yrmcds_cnt *c, const char *name, size_t name_len, uint32_t *serial)
 Send Get command. More...
 
yrmcds_error yrmcds_cnt_acquire (yrmcds_cnt *c, const char *name, size_t name_len, uint32_t resources, uint32_t maximum, uint32_t *serial)
 Send Acquire command. More...
 
yrmcds_error yrmcds_cnt_release (yrmcds_cnt *c, const char *name, size_t name_len, uint32_t resources, uint32_t *serial)
 Send Release command. More...
 
yrmcds_error yrmcds_cnt_stats (yrmcds_cnt *c, uint32_t *serial)
 Send Stats command. More...
 
yrmcds_error yrmcds_cnt_dump (yrmcds_cnt *c, uint32_t *serial)
 Send Dump command. More...
 

Detailed Description

libyrmcds public API.

(C) 2013-2016 Cybozu.