MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
engine.h
1 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 #ifndef MEMCACHED_ENGINE_H
3 #define MEMCACHED_ENGINE_H
4 
5 #include <sys/types.h>
6 #include <stdint.h>
7 #include <stdio.h>
8 
9 #include "memcached/types.h"
10 #include "memcached/protocol_binary.h"
11 #include "memcached/config_parser.h"
12 #include "memcached/server_api.h"
13 #include "memcached/callback.h"
14 #include "memcached/extension.h"
15 #include "memcached/vbucket.h"
16 #include "memcached/engine_common.h"
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
49 #define ENGINE_INTERFACE_VERSION 1
50 
60  typedef void (*ADD_STAT)(const char *key, const uint16_t klen,
61  const char *val, const uint32_t vlen,
62  const void *cookie);
63 
80  typedef bool (*ADD_RESPONSE)(const void *key, uint16_t keylen,
81  const void *ext, uint8_t extlen,
82  const void *body, uint32_t bodylen,
83  uint8_t datatype, uint16_t status,
84  uint64_t cas, const void *cookie);
85 
86 
90 #ifdef __WIN32__
91 #undef interface
92 #endif
94  const void *key; /* THis isn't going to work from a memory management perspective */
95  size_t nkey;
96  };
97 
98  /* This is typedefed in types.h */
100  uint64_t interface;
101  SERVER_CORE_API *core;
102  SERVER_STAT_API *stat;
103  SERVER_EXTENSION_API *extension;
104  SERVER_CALLBACK_API *callback;
105  ENGINE_HANDLE *engine;
106  SERVER_LOG_API *log;
107  SERVER_COOKIE_API *cookie;
108  };
109 
110  typedef enum { TAP_MUTATION = 1,
111  TAP_DELETION,
112  TAP_FLUSH,
113  TAP_OPAQUE,
114  TAP_VBUCKET_SET,
115  TAP_ACK,
116  TAP_DISCONNECT,
117  TAP_NOOP,
118  TAP_PAUSE,
119  TAP_CHECKPOINT_START,
120  TAP_CHECKPOINT_END } tap_event_t;
121 
144  typedef tap_event_t (*TAP_ITERATOR)(ENGINE_HANDLE* handle,
145  const void *cookie,
146  item **item,
147  void **engine_specific,
148  uint16_t *nengine_specific,
149  uint8_t *ttl,
150  uint16_t *flags,
151  uint32_t *seqno,
152  uint16_t *vbucket);
153 
166  typedef ENGINE_ERROR_CODE (*CREATE_INSTANCE)(uint64_t interface,
167  GET_SERVER_API get_server_api,
168  ENGINE_HANDLE** handle);
169 
170  typedef enum {
175  ENGINE_FEATURE_MULTI_TENANCY,
176  ENGINE_FEATURE_LRU, /* Cache implements an LRU */
177  ENGINE_FEATURE_VBUCKET /* Cache implements virtual buckets */
178 
179 #define LAST_REGISTERED_ENGINE_FEATURE ENGINE_FEATURE_VBUCKET
181 
182  typedef struct {
187  uint32_t feature;
192  const char *description;
193  } feature_info;
194 
195  typedef struct {
199  const char *description;
203  uint32_t num_features;
207  feature_info features[1];
208  } engine_info;
209 
213  typedef struct engine_interface_v1 {
217  struct engine_interface interface;
218 
225  const engine_info* (*get_info)(ENGINE_HANDLE* handle);
226 
234  ENGINE_ERROR_CODE (*initialize)(ENGINE_HANDLE* handle,
235  const char* config_str);
236 
243  void (*destroy)(ENGINE_HANDLE* handle, const bool force);
244 
245  /*
246  * Item operations.
247  */
248 
264  ENGINE_ERROR_CODE (*allocate)(ENGINE_HANDLE* handle,
265  const void* cookie,
266  item **item,
267  const void* key,
268  const size_t nkey,
269  const size_t nbytes,
270  const int flags,
271  const rel_time_t exptime);
272 
284  ENGINE_ERROR_CODE (*remove)(ENGINE_HANDLE* handle,
285  const void* cookie,
286  const void* key,
287  const size_t nkey,
288  uint64_t cas,
289  uint16_t vbucket);
290 
291  ENGINE_ERROR_CODE (*bind)(ENGINE_HANDLE* handle,
292  const void* cookie,
293  const void* name,
294  const size_t name_len);
303  void (*release)(ENGINE_HANDLE* handle, const
304  void *cookie,
305  item* item);
306 
314  void (*clean_engine)(ENGINE_HANDLE* handle,
315  const void *cookie,
316  void* engine_data);
317 
330  ENGINE_ERROR_CODE (*get)(ENGINE_HANDLE* handle,
331  const void* cookie,
332  item** item,
333  const void* key,
334  const int nkey,
335  uint16_t vbucket);
336 
349  ENGINE_ERROR_CODE (*store)(ENGINE_HANDLE* handle,
350  const void *cookie,
351  item* item,
352  uint64_t *cas,
353  ENGINE_STORE_OPERATION operation,
354  uint16_t vbucket);
355 
374  ENGINE_ERROR_CODE (*arithmetic)(ENGINE_HANDLE* handle,
375  const void* cookie,
376  const void* key,
377  const int nkey,
378  const bool increment,
379  const bool create,
380  const uint64_t delta,
381  const uint64_t initial,
382  const rel_time_t exptime,
383  uint64_t *cas,
384  uint64_t *result,
385  uint16_t vbucket);
386 
396  ENGINE_ERROR_CODE (*flush)(ENGINE_HANDLE* handle,
397  const void* cookie, time_t when);
398 
399  /*
400  * Statistics
401  */
402 
414  ENGINE_ERROR_CODE (*get_stats)(ENGINE_HANDLE* handle,
415  const void* cookie,
416  const char* stat_key,
417  int nkey,
418  ADD_STAT add_stat);
419 
426  void (*reset_stats)(ENGINE_HANDLE* handle, const void *cookie);
427 
431  void *(*get_stats_struct)(ENGINE_HANDLE* handle,
432  const void* cookie);
433 
437  ENGINE_ERROR_CODE (*aggregate_stats)(ENGINE_HANDLE* handle,
438  const void* cookie,
439  void (*callback)(void*, void*),
440  void*);
441 
442 
453  ENGINE_ERROR_CODE (*unknown_command)(ENGINE_HANDLE* handle,
454  const void* cookie,
456  ADD_RESPONSE response);
457 
458  /* TAP operations */
459 
484  ENGINE_ERROR_CODE (*tap_notify)(ENGINE_HANDLE* handle,
485  const void *cookie,
486  void *engine_specific,
487  uint16_t nengine,
488  uint8_t ttl,
489  uint16_t tap_flags,
490  tap_event_t tap_event,
491  uint32_t tap_seqno,
492  const void *key,
493  size_t nkey,
494  uint32_t flags,
495  uint32_t exptime,
496  uint64_t cas,
497  const void *data,
498  size_t ndata,
499  uint16_t vbucket);
500 
512  TAP_ITERATOR (*get_tap_iterator)(ENGINE_HANDLE* handle, const void* cookie,
513  const void* client, size_t nclient,
514  uint32_t flags,
515  const void* userdata, size_t nuserdata);
516 
520  void (*item_set_cas)(ENGINE_HANDLE *handle, const void *cookie,
521  item *item, uint64_t cas);
522 
536  bool (*get_item_info)(ENGINE_HANDLE *handle,
537  const void *cookie,
538  const item* item,
540 
541 
551  size_t (*errinfo)(ENGINE_HANDLE *handle, const void* cookie,
552  char *buffer, size_t buffsz);
553 
554 
555 
557 
562 #ifdef __cplusplus
563 }
564 #endif
565 
566 #endif