2 +--------------------------------------------------------------------+
3 | libmemcached-awesome - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020-2021 Michael Wallner https://awesome.co/ |
13 +--------------------------------------------------------------------+
25 # define MEMCACHED_NI_MAXHOST NI_MAXHOST
27 # define MEMCACHED_NI_MAXHOST 1025
31 # define MEMCACHED_NI_MAXSERV NI_MAXSERV
33 # define MEMCACHED_NI_MAXSERV 32
36 #include "libmemcached/string.hpp"
38 // @todo Complete class transformation
39 struct memcached_instance_st {
40 in_port_t port() const { return port_; }
42 void port(in_port_t arg) { port_ = arg; }
44 void mark_server_as_clean() {
45 server_failure_counter = 0;
46 server_timeout_counter = 0;
56 bool is_shutting_down() const;
58 void start_close_socket();
62 uint32_t response_count() const { return cursor_active_; }
67 bool is_shutting_down;
75 short events(void) { return _events; }
77 short revents(void) { return _revents; }
79 const char *hostname() { return _hostname; }
81 void hostname(const memcached_string_t &hostname_) {
83 memcpy(_hostname, hostname_.c_str, hostname_.size);
84 _hostname[hostname_.size] = 0;
86 memcpy(_hostname, memcached_literal_param("localhost"));
87 _hostname[memcached_literal_param_size("localhost")] = 0;
94 uint32_t cursor_active_;
96 memcached_socket_t fd;
97 uint32_t io_bytes_sent; /* # bytes sent since last read */
99 uint32_t server_failure_counter;
100 uint64_t server_failure_counter_query_id;
101 uint32_t server_timeout_counter;
102 uint64_t server_timeout_counter_query_id;
105 enum memcached_server_state_t state;
112 uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set.
113 uint8_t micro_version; // ditto, and note that this is the third, not second version bit
114 uint8_t minor_version; // ditto
115 memcached_connection_t type;
117 size_t read_buffer_length;
118 size_t write_buffer_offset;
119 struct addrinfo *address_info;
120 struct addrinfo *address_info_next;
122 struct memcached_st *root;
123 uint64_t limit_maxbytes;
124 struct memcached_error_t *error_messages;
125 char read_buffer[MEMCACHED_MAX_BUFFER];
126 char write_buffer[MEMCACHED_MAX_BUFFER];
127 char _hostname[MEMCACHED_NI_MAXHOST];
129 void clear_addrinfo() {
131 freeaddrinfo(address_info);
133 address_info_next = NULL;
138 memcached_instance_st *instance_create_with(memcached_st *memc, memcached_instance_st *self,
139 const memcached_string_t &_hostname,
140 const in_port_t port, uint32_t weight,
141 const memcached_connection_t type);
143 memcached_return_t memcached_instance_push(memcached_st *ptr, const memcached_instance_st *,
146 void instance_free(memcached_instance_st *);