memcache.h
author Tero Marttila <terom@fixme.fi>
Thu, 28 Aug 2008 01:34:14 +0300
changeset 44 03a7e064f833
parent 43 e5b714190dee
child 45 10d514029c64
permissions -rw-r--r--
stub functions and documentation
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#ifndef MEMCACHE_H
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
#define MEMCACHE_H
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
 * A libevent based memcached client that aims for high performance, concurrency and low latency.
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
#include "config.h"
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
 * Used to store the global information for a memcache context. A context contains both servers and active connections.
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
struct memcache;
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
 * A transaction.
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
struct memcache_req;
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
 * Keys used
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
struct memcache_key {
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    24
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    25
     * Pointer to a char buffer containing the key itself.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    26
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    27
     * A key is a text tring which should uniquely identify a cache entry.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    28
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    29
     * The length limit for a key is usually 250 characters, but this is imposed by the server side (a longer key will
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    30
     * presumeably cause a CLIENT_ERROR reply).
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    31
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    32
     * The key should presumeably also not contain any spaces, carriage returns or newlines, as these are used to
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    33
     * delimit tokens in the protocol itself.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    34
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    35
     * The buffer does not need to be zero-terminated.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    36
     */
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    37
    char *buf;
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    38
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    39
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    40
     * The length of the key buffer in bytes. This does not include a NUL byte.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    41
     */
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
    size_t len;
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
};
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
 * Object attributes
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
struct memcache_obj {
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    49
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    50
     * An arbitrary 16-bit (32-bit for >1.2.1) that the server stores transparently.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    51
     */
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
    unsigned int flags;
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    53
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    54
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    55
     * Expiration time. If non-zero, either an offset in seconds from current time (up to 60*60*24*30 seconds, or 30d),
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    56
     * or an absolute 32-bit unix timestamp.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    57
     */
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
    time_t exptime;
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    59
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    60
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    61
     * Number of bytes in the entry. This may be zero, in which case there will be no data.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    62
     */
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
    size_t bytes;
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    64
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    65
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    66
     * Used for the CMD_STORE_CAS command. An unique 64-bit value that changes if the entry is modified.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    67
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    68
     * Not needed for other commands, and may or may not be provided by CMD_FETCH_GET (will be set to zero).
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    69
     */
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    70
    unsigned long long cas;
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    71
};
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    72
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    73
/*
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    74
 * Object data
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    75
 */
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    76
struct memcache_buf {
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    77
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    78
     * The char buffer containing the data.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    79
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    80
    char *data;
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    81
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    82
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    83
     * The total length of the char buffer, and thence the cache entry.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    84
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    85
    size_t len;
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    86
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    87
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    88
     * The amount of data currently available in the buffer. This is used to provide streaming fetches.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    89
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    90
     * This field is *IMPORTANT*! Don't disregard it, or you *will* get incomplete data.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    91
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    92
    size_t offset;
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    93
};
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    94
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    95
/*
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    96
 * Available commands
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
enum memcache_command {
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    99
    MEMCACHE_CMD_INVALID,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   100
    
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   101
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   102
     * Retrieve the value of a key from the memcached server. 
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   103
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   104
     * If the key exists, you will get a RPL_VALUE reply followed by a RPL_END reply. 
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   105
     * If it does not exist, you will just get a RPL_END reply.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   106
     */
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   107
    MEMCACHE_CMD_FETCH_GET,
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   108
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   109
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   110
     * Store this data.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   111
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   112
     * Returns either RPL_STORED or RPL_NOT_STORED.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   113
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   114
    MEMCACHE_CMD_STORE_SET,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   115
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   116
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   117
     * Store this data, but only if the server doesn't already hold data for this key.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   118
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   119
     * Returns either RPL_STORED or RPL_NOT_STORED.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   120
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   121
    MEMCACHE_CMD_STORE_ADD,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   122
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   123
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   124
     * Store this data, but only if the server does already hold data for this key.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   125
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   126
     * Returns either RPL_STORED or RPL_NOT_STORED.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   127
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   128
    MEMCACHE_CMD_STORE_REPLACE,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   129
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   130
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   131
     * Add this data to an existing key after existing data.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   132
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   133
     * obj.flags and obj.exptime are ignored.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   134
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   135
     * Returns ???
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   136
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   137
    MEMCACHE_CMD_STORE_APPEND,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   138
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   139
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   140
     * Add this data to an existing key before existing data.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   141
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   142
     * obj.flags and obj.exptime are ignored.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   143
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   144
     * Returns ???
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   145
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   146
    MEMCACHE_CMD_STORE_PREPEND,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   147
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   148
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   149
     * Check and Set - store this data but only if no one else had updated it since I last fetched it.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   150
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   151
     * obj.cas is required.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   152
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   153
     * Returns RPL_STORED, RPL_NOT_STORED, RPL_EXISTS (data has been modified), or RPL_NOT_FOUND (the item does not
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   154
     * exist or has been deleted).
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   155
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   156
    MEMCACHE_CMD_STORE_CAS,
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   157
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   158
    MEMCACHE_CMD_MAX,
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   159
};
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   160
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   161
/*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   162
 * Replies from the server
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   163
 */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   164
enum memcache_reply {
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   165
    MEMCACHE_RPL_INVALID,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   166
    
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   167
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   168
     * The library sent an unknown command. This probably means the server is not compatible with said command.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   169
     */
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   170
    MEMCACHE_RPL_ERROR,
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   171
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   172
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   173
     * There was an error in the request that the library sent. The error message is printed out via ERROR.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   174
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   175
    MEMCACHE_RPL_CLIENT_ERROR,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   176
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   177
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   178
     * There was an error with the server when processing the request. The error message is printed out via ERROR.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   179
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   180
    MEMCACHE_RPL_SERVER_ERROR,
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   181
    
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   182
    // CMD_FETCH_*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   183
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   184
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   185
     * The given key was found in the cache. The obj attributes are now known, and the buf data is on the way.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   186
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   187
    MEMCACHE_RPL_VALUE,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   188
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   189
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   190
     * No more RPL_VALUE replies will be sent. This may be the only reply sent if the key was not found.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   191
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   192
    MEMCACHE_RPL_END,
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   193
    
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   194
    // CMD_STORE_*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   195
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   196
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   197
     * The object was succesfully stored in the cache.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   198
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   199
    MEMCACHE_RPL_STORED,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   200
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   201
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   202
     * The object was not stored in the cache.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   203
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   204
     * This could be for a number of reasons, perhaps the object is too large, the cache is full, the key is in the
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   205
     * delete queue, or some condition imposed by the STORE_* command was not met.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   206
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   207
    MEMCACHE_RPL_NOT_STORED,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   208
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   209
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   210
     * The item you were trying to store with a STORE_CAS request has been modified since you last fetched it (i.e.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   211
     * obj.cas does not match).
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   212
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   213
    MEMCACHE_RPL_EXISTS,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   214
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   215
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   216
     * The item you were trying to store with a STORE_CAS request did not exist (or has been deleted).
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   217
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   218
    MEMCACHE_RPL_NOT_FOUND,
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   219
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   220
    MEMCACHE_RPL_MAX,
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   221
};
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   222
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
   223
enum memcache_req_state {
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   224
    MEMCACHE_STATE_INVALID,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   225
    
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   226
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   227
     * The request is queued, and has not been sent yet
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   228
     */
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   229
    MEMCACHE_STATE_QUEUED,
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   230
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   231
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   232
     * The request is being sent, and the reply has not yet been received
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   233
     */
42
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
   234
    MEMCACHE_STATE_SEND,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   235
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   236
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   237
     * The reply has been received.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   238
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   239
     * req_reply and req_obj will return a non-NULL value, but there is no reply data yet.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   240
     */
42
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
   241
    MEMCACHE_STATE_REPLY,
43
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
   242
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   243
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   244
     * The reply and part of the reply data has been received.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   245
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   246
     * req_reply, req_obj and req_buf will all return non-NULL values, but buf.offset will be smaller than buf.len.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   247
     */
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   248
    MEMCACHE_STATE_REPLY_DATA,
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   249
    
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   250
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   251
     * The full reply has been received.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   252
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   253
     * req_reply, req_obj will return a non-NULL value, but there is no reply data.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   254
     */
43
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
   255
    MEMCACHE_STATE_DONE,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   256
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   257
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   258
     * The full reply and reply data has been received.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   259
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   260
     * req_reply, req_obj and req_buf will all return non-NULL values, and buf.offset will be equal to buf.len.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   261
     */
43
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
   262
    MEMCACHE_STATE_DATA_DONE,
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   263
    
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   264
    /*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   265
     * An error has occurred.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   266
     *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   267
     * req_reply, req_obj and req_buf may or may not work.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   268
     */
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
   269
    MEMCACHE_STATE_ERROR,
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   270
};
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   271
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   272
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   273
 * Callback used
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   274
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   275
typedef int (*memcache_cb) (struct memcache_req *, void*);
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   276
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   277
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   278
 * Allocate a new memcache context for use with other methods.
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   279
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   280
struct memcache *memcache_alloc (memcache_cb cb_fn);
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   281
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   282
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   283
 * Add a server to the pool of available servers.
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   284
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   285
int memcache_add_server (struct memcache *mc, struct config_endpoint *endpoint, int max_connections);
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   286
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   287
/*
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   288
 * Attempt to fetch a key from the cache.
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   289
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   290
 * The state machine will work as follows:
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   291
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   292
 *  req_state                  multi   req_reply
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   293
 *  ---------------------------------------------
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   294
 *  STATE_QUEUE                 ?
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   295
 *  STATE_SEND
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   296
 *  STATE_REPLY                         RPL_VALUE
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   297
 *      STATE_REPLY_DATA        *       RPL_VALUE
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   298
 *      STATE_DATA_DONE                 RPL_END
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   299
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   300
 *      STATE_DONE                      RPL_END
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   301
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   302
 *  STATE_ERROR                         RPL_{ERROR,CLIENT_ERROR,SERVER_ERROR}
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   303
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   304
 * The item attributes/data can be accessed via req_obj/req_buf as described in `enum memcache_state`.
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   305
 */
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   306
struct memcache_req *memcache_fetch (struct memcache *mc, const struct memcache_key *key, void *cb_arg);
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   307
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   308
/*
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   309
 * Attempt to store an item into the cache.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   310
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   311
 * The cmd argument can be used to specify what CMD_STORE_* command to use.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   312
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   313
 * The given memcache_key is copied, including the char array pointed to by buf.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   314
 * Both obj and buf are also copied, but buf.data will not be copied - the pointer must remain valid until the request is done.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   315
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   316
 * The state machine will work as follows:
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   317
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   318
 *  req_state               multi       req_reply
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   319
 *  ---------------------------------------------
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   320
 *  STATE_QUEUE             ?
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   321
 *  STATE_SEND
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   322
 *  STATE_REPLY                         RPL_{STORED,NOT_STORED,EXISTS,NOT_FOUND}
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   323
 *  STATE_DONE                          RPL_{STORED,NOT_STORED,EXISTS,NOT_FOUND}
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   324
 * 
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   325
 *  STATE_ERROR                         RPL_{ERROR,CLIENT_ERROR,SERVER_ERROR}
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   326
 *
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   327
 */
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   328
struct memcache_req *memcache_store (struct memcache *mc, enum memcache_command cmd, const struct memcache_key *key, const struct memcache_obj *obj, const struct memcache_buf *buf, void *cb_arg);
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   329
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   330
/*
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   331
 * Request state.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   332
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   333
 * Should always return a valid value.
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   334
 */ 
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
   335
enum memcache_req_state memcache_req_state (struct memcache_req *req);
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   336
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   337
/*
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   338
 * Request command.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   339
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   340
 * Should always return a valid value.
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   341
 */
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   342
enum memcache_command memcache_req_cmd (struct memcache_req *req);
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   343
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   344
/*
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   345
 * Request reply.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   346
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   347
 * Will return a valid value in the STATE_REPLY, STATE_REPLY_DATA, STATE_DONE and STATE_DATA_DONE states.
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   348
 */
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   349
enum memcache_reply memcache_req_reply (struct memcache_req *req);
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   350
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   351
/*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   352
 * Request key.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   353
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   354
 * Will return a valid valuein all states
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   355
 */
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   356
const struct memcache_key *keymemcache_req_key (struct memcache_req *req);
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   357
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   358
/*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   359
 * Request data.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   360
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   361
 * Will return a valid value in the STATE_REPLY, STATE_REPLY_DATA, STATE_DONE and STATE_DATA_DONE states.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   362
 */
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   363
const struct memcache_obj *memcache_req_obj (struct memcache_req *req);
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   364
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   365
/*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   366
 * Request buf.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   367
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   368
 * Will return a valid value in the STATE_REPLY_DATA and STATE_DATA_DONE states.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   369
 *
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   370
 * Note that buf.offset may be less than buf.len in the STATE_REPLY_DATA state.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   371
 */
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   372
const struct memcache_buf *memcache_req_buf (struct memcache_req *req);
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   373
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   374
/*
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   375
 * Free a req that is in the STATE_DONE, STATE_DATA_DONE or STATE_ERROR state.
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   376
 */
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
   377
void memcache_req_free (struct memcache_req *req);
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   378
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   379
#endif /* MEMCACHE_H */