a3f9d279306d9e8a705f9163f2de611a5e6d3bff
[m6w6/libmemcached] / libmemcached-1.0 / struct / memcached.h
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Libmemcached library
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2006-2009 Brian Aker All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38 #pragma once
39
40 struct memcached_st {
41 /**
42 @note these are static and should not change without a call to behavior.
43 */
44 struct {
45 bool is_purging:1;
46 bool is_processing_input:1;
47 bool is_time_for_rebuild:1;
48 } state;
49
50 struct {
51 // Everything below here is pretty static.
52 bool auto_eject_hosts:1;
53 bool binary_protocol:1;
54 bool buffer_requests:1;
55 bool hash_with_namespace:1;
56 bool no_block:1; // Don't block
57 bool reply:1;
58 bool randomize_replica_read:1;
59 bool support_cas:1;
60 bool tcp_nodelay:1;
61 bool use_sort_hosts:1;
62 bool use_udp:1;
63 bool verify_key:1;
64 bool tcp_keepalive:1;
65 } flags;
66
67 memcached_server_distribution_t distribution;
68 hashkit_st hashkit;
69 struct {
70 unsigned int version;
71 } server_info;
72 uint32_t number_of_hosts;
73 memcached_server_st *servers;
74 memcached_server_st *last_disconnected_server;
75 int32_t snd_timeout;
76 int32_t rcv_timeout;
77 uint32_t server_failure_limit;
78 uint32_t io_msg_watermark;
79 uint32_t io_bytes_watermark;
80 uint32_t io_key_prefetch;
81 uint32_t tcp_keepidle;
82 int32_t poll_timeout;
83 int32_t connect_timeout; // How long we will wait on connect() before we will timeout
84 int32_t retry_timeout;
85 int32_t dead_timeout;
86 int send_size;
87 int recv_size;
88 void *user_data;
89 uint64_t query_id;
90 uint32_t number_of_replicas;
91 memcached_result_st result;
92
93 struct {
94 bool weighted;
95 uint32_t continuum_count; // Ketama
96 uint32_t continuum_points_counter; // Ketama
97 time_t next_distribution_rebuild; // Ketama
98 memcached_continuum_item_st *continuum; // Ketama
99 } ketama;
100
101 struct memcached_virtual_bucket_t *virtual_bucket;
102
103 struct memcached_allocator_t allocators;
104
105 memcached_clone_fn on_clone;
106 memcached_cleanup_fn on_cleanup;
107 memcached_trigger_key_fn get_key_failure;
108 memcached_trigger_delete_key_fn delete_trigger;
109 memcached_callback_st *callbacks;
110 struct memcached_sasl_st sasl;
111 struct memcached_error_t *error_messages;
112 struct memcached_array_st *_namespace;
113 struct {
114 uint32_t initial_pool_size;
115 uint32_t max_pool_size;
116 int32_t version; // This is used by pool and others to determine if the memcached_st is out of date.
117 struct memcached_array_st *filename;
118 } configure;
119 struct {
120 bool is_allocated:1;
121 } options;
122
123 };