13c3268a9STrond Norbye/* LibMemcached
23c3268a9STrond Norbye * Copyright (C) 2006-2009 Brian Aker
33c3268a9STrond Norbye * All rights reserved.
43c3268a9STrond Norbye *
53c3268a9STrond Norbye * Use and distribution licensed under the BSD license.  See
63c3268a9STrond Norbye * the COPYING file in the parent directory for full text.
73c3268a9STrond Norbye *
83c3268a9STrond Norbye * Summary: interface for memcached server
93c3268a9STrond Norbye * Description: main include file for libmemcached
103c3268a9STrond Norbye *
113c3268a9STrond Norbye */
123c3268a9STrond Norbye
133c3268a9STrond Norbye#ifndef __LIBMEMCACHED_MEMCACHED_H__
143c3268a9STrond Norbye#define __LIBMEMCACHED_MEMCACHED_H__
153c3268a9STrond Norbye
163c3268a9STrond Norbye#include <inttypes.h>
173c3268a9STrond Norbye#include <stdlib.h>
183c3268a9STrond Norbye#include <sys/types.h>
193c3268a9STrond Norbye
203c3268a9STrond Norbye
213c3268a9STrond Norbye#if !defined(__cplusplus)
223c3268a9STrond Norbye# include <stdbool.h>
233c3268a9STrond Norbye#endif
243c3268a9STrond Norbye
253c3268a9STrond Norbye#include <libmemcached/visibility.h>
263c3268a9STrond Norbye#include <libmemcached/configure.h>
273c3268a9STrond Norbye#include <libmemcached/platform.h>
283c3268a9STrond Norbye#include <libmemcached/constants.h>
293c3268a9STrond Norbye#include <libmemcached/types.h>
303c3268a9STrond Norbye#include <libmemcached/string.h>
313c3268a9STrond Norbye#include <libmemcached/stats.h>
323c3268a9STrond Norbye#include <libhashkit/hashkit.h>
333c3268a9STrond Norbye/* Everything above this line must be in the order specified. */
343c3268a9STrond Norbye#include <libmemcached/allocators.h>
353c3268a9STrond Norbye#include <libmemcached/analyze.h>
363c3268a9STrond Norbye#include <libmemcached/auto.h>
373c3268a9STrond Norbye#include <libmemcached/behavior.h>
383c3268a9STrond Norbye#include <libmemcached/callback.h>
393c3268a9STrond Norbye#include <libmemcached/delete.h>
403c3268a9STrond Norbye#include <libmemcached/dump.h>
413c3268a9STrond Norbye#include <libmemcached/fetch.h>
423c3268a9STrond Norbye#include <libmemcached/flush.h>
433c3268a9STrond Norbye#include <libmemcached/flush_buffers.h>
443c3268a9STrond Norbye#include <libmemcached/get.h>
453c3268a9STrond Norbye#include <libmemcached/hash.h>
463c3268a9STrond Norbye#include <libmemcached/parse.h>
473c3268a9STrond Norbye#include <libmemcached/quit.h>
483c3268a9STrond Norbye#include <libmemcached/result.h>
493c3268a9STrond Norbye#include <libmemcached/server.h>
503c3268a9STrond Norbye#include <libmemcached/server_list.h>
513c3268a9STrond Norbye#include <libmemcached/storage.h>
523c3268a9STrond Norbye#include <libmemcached/strerror.h>
533c3268a9STrond Norbye#include <libmemcached/verbosity.h>
543c3268a9STrond Norbye#include <libmemcached/version.h>
553c3268a9STrond Norbye#include <libmemcached/sasl.h>
563c3268a9STrond Norbye
573c3268a9STrond Norbyestruct memcached_st {
583c3268a9STrond Norbye  /**
593c3268a9STrond Norbye    @note these are static and should not change without a call to behavior.
603c3268a9STrond Norbye  */
613c3268a9STrond Norbye  struct {
623c3268a9STrond Norbye    bool is_purging:1;
633c3268a9STrond Norbye    bool is_processing_input:1;
643c3268a9STrond Norbye    bool is_time_for_rebuild:1;
653c3268a9STrond Norbye  } state;
663c3268a9STrond Norbye  struct {
673c3268a9STrond Norbye    /* Everything below here is pretty static. */
683c3268a9STrond Norbye    bool auto_eject_hosts:1;
693c3268a9STrond Norbye    bool binary_protocol:1;
703c3268a9STrond Norbye    bool buffer_requests:1;
713c3268a9STrond Norbye    bool cork:1;
723c3268a9STrond Norbye    bool hash_with_prefix_key:1;
733c3268a9STrond Norbye    bool ketama_weighted:1;
743c3268a9STrond Norbye    bool no_block:1; /* Don't block */
753c3268a9STrond Norbye    bool no_reply:1;
763c3268a9STrond Norbye    bool randomize_replica_read:1;
773c3268a9STrond Norbye    bool reuse_memory:1;
783c3268a9STrond Norbye    bool support_cas:1;
793c3268a9STrond Norbye    bool tcp_nodelay:1;
803c3268a9STrond Norbye    bool use_cache_lookups:1;
813c3268a9STrond Norbye    bool use_sort_hosts:1;
823c3268a9STrond Norbye    bool use_udp:1;
833c3268a9STrond Norbye    bool verify_key:1;
843c3268a9STrond Norbye    bool tcp_keepalive:1;
853c3268a9STrond Norbye  } flags;
863c3268a9STrond Norbye  memcached_server_distribution_t distribution;
873c3268a9STrond Norbye  hashkit_st hashkit;
883c3268a9STrond Norbye  uint32_t continuum_points_counter; /* Ketama */
893c3268a9STrond Norbye  uint32_t number_of_hosts;
903c3268a9STrond Norbye  memcached_server_st *servers;
913c3268a9STrond Norbye  memcached_server_st *last_disconnected_server;
923c3268a9STrond Norbye  int32_t snd_timeout;
933c3268a9STrond Norbye  int32_t rcv_timeout;
943c3268a9STrond Norbye  uint32_t server_failure_limit;
953c3268a9STrond Norbye  uint32_t io_msg_watermark;
963c3268a9STrond Norbye  uint32_t io_bytes_watermark;
973c3268a9STrond Norbye  uint32_t io_key_prefetch;
983c3268a9STrond Norbye  uint32_t tcp_keepidle;
993c3268a9STrond Norbye  int cached_errno;
1003c3268a9STrond Norbye  int32_t poll_timeout;
1013c3268a9STrond Norbye  int32_t connect_timeout;
1023c3268a9STrond Norbye  int32_t retry_timeout;
1033c3268a9STrond Norbye  uint32_t continuum_count; /* Ketama */
1043c3268a9STrond Norbye  int send_size;
1053c3268a9STrond Norbye  int recv_size;
1063c3268a9STrond Norbye  void *user_data;
1073c3268a9STrond Norbye  time_t next_distribution_rebuild; /* Ketama */
1083c3268a9STrond Norbye  size_t prefix_key_length;
1093c3268a9STrond Norbye  uint32_t number_of_replicas;
1103c3268a9STrond Norbye  hashkit_st distribution_hashkit;
1113c3268a9STrond Norbye  memcached_result_st result;
1123c3268a9STrond Norbye  memcached_continuum_item_st *continuum; /* Ketama */
1133c3268a9STrond Norbye
1143c3268a9STrond Norbye  struct _allocators_st {
1153c3268a9STrond Norbye    memcached_calloc_fn calloc;
1163c3268a9STrond Norbye    memcached_free_fn free;
1173c3268a9STrond Norbye    memcached_malloc_fn malloc;
1183c3268a9STrond Norbye    memcached_realloc_fn realloc;
1193c3268a9STrond Norbye    void *context;
1203c3268a9STrond Norbye  } allocators;
1213c3268a9STrond Norbye
1223c3268a9STrond Norbye  memcached_clone_fn on_clone;
1233c3268a9STrond Norbye  memcached_cleanup_fn on_cleanup;
1243c3268a9STrond Norbye  memcached_trigger_key_fn get_key_failure;
1253c3268a9STrond Norbye  memcached_trigger_delete_key_fn delete_trigger;
1263c3268a9STrond Norbye  memcached_callback_st *callbacks;
1273c3268a9STrond Norbye  struct memcached_sasl_st sasl;
1283c3268a9STrond Norbye  char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
1293c3268a9STrond Norbye  struct {
1303c3268a9STrond Norbye    bool is_allocated:1;
1313c3268a9STrond Norbye  } options;
1323c3268a9STrond Norbye
1333c3268a9STrond Norbye};
1343c3268a9STrond Norbye
1353c3268a9STrond Norbye#ifdef __cplusplus
1363c3268a9STrond Norbyeextern "C" {
1373c3268a9STrond Norbye#endif
1383c3268a9STrond Norbye
1393c3268a9STrond NorbyeLIBMEMCACHED_API
1403c3268a9STrond Norbyevoid memcached_servers_reset(memcached_st *ptr);
1413c3268a9STrond Norbye
1423c3268a9STrond NorbyeLIBMEMCACHED_API
1433c3268a9STrond Norbyememcached_st *memcached_create(memcached_st *ptr);
1443c3268a9STrond Norbye
1453c3268a9STrond NorbyeLIBMEMCACHED_API
1463c3268a9STrond Norbyevoid memcached_free(memcached_st *ptr);
1473c3268a9STrond Norbye
1483c3268a9STrond NorbyeLIBMEMCACHED_API
1493c3268a9STrond Norbyevoid memcached_reset_last_disconnected_server(memcached_st *ptr);
1503c3268a9STrond Norbye
1513c3268a9STrond NorbyeLIBMEMCACHED_API
1523c3268a9STrond Norbyememcached_st *memcached_clone(memcached_st *clone, const memcached_st *ptr);
1533c3268a9STrond Norbye
1543c3268a9STrond NorbyeLIBMEMCACHED_API
1553c3268a9STrond Norbyevoid *memcached_get_user_data(const memcached_st *ptr);
1563c3268a9STrond Norbye
1573c3268a9STrond NorbyeLIBMEMCACHED_API
1583c3268a9STrond Norbyevoid *memcached_set_user_data(memcached_st *ptr, void *data);
1593c3268a9STrond Norbye
1603c3268a9STrond NorbyeLIBMEMCACHED_API
1613c3268a9STrond Norbyememcached_return_t memcached_push(memcached_st *destination, const memcached_st *source);
1623c3268a9STrond Norbye
1633c3268a9STrond NorbyeLIBMEMCACHED_API
1643c3268a9STrond Norbyememcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key);
1653c3268a9STrond Norbye
1663c3268a9STrond NorbyeLIBMEMCACHED_API
1673c3268a9STrond Norbyeuint32_t memcached_server_count(const memcached_st *);
1683c3268a9STrond Norbye
1693c3268a9STrond Norbye#ifdef __cplusplus
1703c3268a9STrond Norbye} /* extern "C" */
1713c3268a9STrond Norbye#endif
1723c3268a9STrond Norbye
1733c3268a9STrond Norbye#endif /* __LIBMEMCACHED_MEMCACHED_H__ */
174