4 memcached_response() is used to determine the return result
5 from an issued command.
10 memcached_return
memcached_response(memcached_st
*ptr
,
11 char *buffer
, size_t buffer_length
,
12 unsigned int server_key
)
17 memset(buffer
, 0, buffer_length
);
23 unsigned int read_length
;
24 read_length
= read(ptr
->hosts
[server_key
].fd
, buffer_ptr
, 1);
27 return MEMCACHED_UNKNOWN_READ_FAILURE
;
29 if (*buffer_ptr
== '\n')
38 return MEMCACHED_SUCCESS
;
40 return MEMCACHED_SUCCESS
;
41 case 'S': /* STORED STATS SERVER_ERROR */
43 if (buffer
[1] == 'T') /* STORED STATS */
44 return MEMCACHED_SUCCESS
;
45 else if (buffer
[1] == 'E')
46 return MEMCACHED_SERVER_ERROR
;
48 return MEMCACHED_UNKNOWN_READ_FAILURE
;
50 case 'D': /* DELETED */
51 return MEMCACHED_SUCCESS
;
52 case 'N': /* NOT_FOUND */
55 return MEMCACHED_NOTFOUND
;
56 else if (buffer
[4] == 'S')
57 return MEMCACHED_NOTSTORED
;
59 return MEMCACHED_UNKNOWN_READ_FAILURE
;
61 case 'E': /* PROTOCOL ERROR or END */
64 return MEMCACHED_NOTFOUND
;
65 else if (buffer
[1] == 'R')
66 return MEMCACHED_PROTOCOL_ERROR
;
68 return MEMCACHED_UNKNOWN_READ_FAILURE
;
70 case 'C': /* CLIENT ERROR */
71 return MEMCACHED_CLIENT_ERROR
;
73 return MEMCACHED_UNKNOWN_READ_FAILURE
;
75 return MEMCACHED_READ_FAILURE
;
78 return MEMCACHED_SUCCESS
;