2 * Summary: interface for memcached server
3 * Description: main include file for libmemcached
5 * Copy: See Copyright for the status of this software.
10 #ifndef __MEMCACHED_H__
11 #define __MEMCACHED_H__
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
31 typedef struct memcached_st memcached_st
;
32 typedef struct memcached_stat_st memcached_stat_st
;
33 typedef struct memcached_host_st memcached_host_st
;
35 #define MEMCACHED_DEFAULT_PORT 11211
36 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
37 #define HUGE_STRING_LEN 8196
42 MEMCACHED_HOST_LOCKUP_FAILURE
,
43 MEMCACHED_CONNECTION_FAILURE
,
44 MEMCACHED_CONNECTION_BIND_FAILURE
,
45 MEMCACHED_WRITE_FAILURE
,
46 MEMCACHED_READ_FAILURE
,
47 MEMCACHED_UNKNOWN_READ_FAILURE
,
48 MEMCACHED_PROTOCOL_ERROR
,
49 MEMCACHED_CLIENT_ERROR
,
50 MEMCACHED_SERVER_ERROR
,
51 MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE
,
52 MEMCACHED_DATA_EXISTS
,
53 MEMCACHED_DATA_DOES_NOT_EXIST
,
56 MEMCACHED_MEMORY_ALLOCATION_FAILURE
,
57 MEMCACHED_PARTIAL_READ
,
61 MEMCACHED_NOT_ALLOCATED
= 0,
62 MEMCACHED_ALLOCATED
= 1,
63 } memcached_allocated
;
65 struct memcached_host_st
{
69 memcached_host_st
*next
;
72 struct memcached_stat_st
{
78 unsigned int pointer_size
;
79 unsigned int rusage_user
;
80 unsigned int rusage_system
;
81 unsigned int rusage_user_seconds
;
82 unsigned int rusage_user_microseconds
;
83 unsigned int rusage_system_seconds
;
84 unsigned int rusage_system_microseconds
;
85 unsigned int curr_items
;
86 unsigned int total_items
;
87 unsigned long long bytes
;
88 unsigned int curr_connections
;
89 unsigned int total_connections
;
90 unsigned int connection_structures
;
91 unsigned long long cmd_get
;
92 unsigned long long cmd_set
;
93 unsigned long long get_hits
;
94 unsigned long long get_misses
;
95 unsigned long long evictions
;
96 unsigned long long bytes_read
;
97 unsigned long long bytes_written
;
98 unsigned int limit_maxbytes
;
101 struct memcached_st
{
102 memcached_allocated is_allocated
;
105 memcached_host_st
*hosts
;
109 memcached_st
*memcached_init(memcached_st
*ptr
);
110 void memcached_deinit(memcached_st
*ptr
);
112 memcached_return
memcached_set(memcached_st
*ptr
, char *key
, size_t key_length
,
113 char *value
, size_t value_length
,
116 memcached_return
memcached_add(memcached_st
*ptr
, char *key
, size_t key_length
,
117 char *value
, size_t value_length
,
120 memcached_return
memcached_replace(memcached_st
*ptr
, char *key
, size_t key_length
,
121 char *value
, size_t value_length
,
124 memcached_return
memcached_delete(memcached_st
*ptr
, char *key
, size_t key_length
,
126 memcached_return
memcached_increment(memcached_st
*ptr
, char *key
, size_t key_length
,
128 memcached_return
memcached_decrement(memcached_st
*ptr
, char *key
, size_t key_length
,
130 memcached_stat_st
**memcached_stat(memcached_st
*ptr
, memcached_return
*error
);
131 memcached_return
memcached_stat_hostname(memcached_stat_st
*stat
, char *args
,
132 char *hostname
, unsigned int port
);
133 memcached_return
memcached_flush(memcached_st
*ptr
, time_t expiration
);
134 memcached_return
memcached_verbosity(memcached_st
*ptr
, unsigned int verbosity
);
135 memcached_return
memcached_quit(memcached_st
*ptr
, char *hostname
, unsigned port
);
136 char *memcached_get(memcached_st
*ptr
, char *key
, size_t key_length
,
137 size_t *value_length
,
139 memcached_return
*error
);
140 memcached_return
memcached_server_add(memcached_st
*ptr
, char *hostname
, unsigned int port
);
141 char *memcached_strerror(memcached_st
*ptr
, memcached_return rc
);
143 /* These are all private, do not use. */
144 memcached_return
memcached_connect(memcached_st
*ptr
);
145 memcached_return
memcached_response(memcached_st
*ptr
,
147 size_t buffer_length
);
153 #endif /* __MEMCACHED_H__ */