1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (c) 2009, Patrick "CaptTofu" Galbraith, Padraig O'Sullivan
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
10
* * Redistributions of source code must retain the above copyright notice,
11
* this list of conditions and the following disclaimer.
12
* * Redistributions in binary form must reproduce the above copyright notice,
13
* this list of conditions and the following disclaimer in the documentation
14
* and/or other materials provided with the distribution.
15
* * Neither the name of Patrick Galbraith nor the names of its contributors
16
* may be used to endorse or promote products derived from this software
17
* without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29
* THE POSSIBILITY OF SUCH DAMAGE.
32
#ifndef DRIZZLE_PLUGIN_MEMCACHED_FUNCTIONS_MEMC_BEHAVIOR_SET_H
33
#define DRIZZLE_PLUGIN_MEMCACHED_FUNCTIONS_MEMC_BEHAVIOR_SET_H
35
#include <drizzled/server_includes.h>
36
#include <drizzled/item/func.h>
38
#include <libmemcached/memcached.h>
43
/* implements memc_behavior_set */
44
class MemcachedBehaviorSet : public Item_str_func
47
MemcachedBehaviorSet()
50
failure_buff("0", &my_charset_bin),
51
success_buff("1", &my_charset_bin),
55
ketama_hash_settings_map()
57
behavior_map.insert(std::pair<const std::string, memcached_behavior>
58
("MEMCACHED_BEHAVIOR_SUPPORT_CAS", MEMCACHED_BEHAVIOR_SUPPORT_CAS));
59
behavior_map.insert(std::pair<const std::string, memcached_behavior>
60
("MEMCACHED_BEHAVIOR_NO_BLOCK", MEMCACHED_BEHAVIOR_NO_BLOCK));
61
behavior_map.insert(std::pair<const std::string, memcached_behavior>
62
("MEMCACHED_BEHAVIOR_TCP_NODELAY", MEMCACHED_BEHAVIOR_TCP_NODELAY));
63
behavior_map.insert(std::pair<const std::string, memcached_behavior>
64
("MEMCACHED_BEHAVIOR_HASH", MEMCACHED_BEHAVIOR_HASH));
65
behavior_map.insert(std::pair<const std::string, memcached_behavior>
66
("MEMCACHED_BEHAVIOR_CACHE_LOOKUPS", MEMCACHED_BEHAVIOR_CACHE_LOOKUPS));
67
behavior_map.insert(std::pair<const std::string, memcached_behavior>
68
("MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE", MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE));
69
behavior_map.insert(std::pair<const std::string, memcached_behavior>
70
("MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE", MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE));
71
behavior_map.insert(std::pair<const std::string, memcached_behavior>
72
("MEMCACHED_BEHAVIOR_BUFFER_REQUESTS", MEMCACHED_BEHAVIOR_BUFFER_REQUESTS));
73
behavior_map.insert(std::pair<const std::string, memcached_behavior>
74
("MEMCACHED_BEHAVIOR_KETAMA", MEMCACHED_BEHAVIOR_KETAMA));
75
behavior_map.insert(std::pair<const std::string, memcached_behavior>
76
("MEMCACHED_BEHAVIOR_POLL_TIMEOUT", MEMCACHED_BEHAVIOR_POLL_TIMEOUT));
77
behavior_map.insert(std::pair<const std::string, memcached_behavior>
78
("MEMCACHED_BEHAVIOR_RETRY_TIMEOUT", MEMCACHED_BEHAVIOR_RETRY_TIMEOUT));
79
behavior_map.insert(std::pair<const std::string, memcached_behavior>
80
("MEMCACHED_BEHAVIOR_DISTRIBUTION", MEMCACHED_BEHAVIOR_DISTRIBUTION));
81
behavior_map.insert(std::pair<const std::string, memcached_behavior>
82
("MEMCACHED_BEHAVIOR_USER_DATA", MEMCACHED_BEHAVIOR_USER_DATA));
83
behavior_map.insert(std::pair<const std::string, memcached_behavior>
84
("MEMCACHED_BEHAVIOR_SORT_HOSTS", MEMCACHED_BEHAVIOR_SORT_HOSTS));
85
behavior_map.insert(std::pair<const std::string, memcached_behavior>
86
("MEMCACHED_BEHAVIOR_VERIFY_KEY", MEMCACHED_BEHAVIOR_VERIFY_KEY));
87
behavior_map.insert(std::pair<const std::string, memcached_behavior>
88
("MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT", MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT));
89
behavior_map.insert(std::pair<const std::string, memcached_behavior>
90
("MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED", MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
91
behavior_map.insert(std::pair<const std::string, memcached_behavior>
92
("MEMCACHED_BEHAVIOR_KETAMA_HASH", MEMCACHED_BEHAVIOR_KETAMA_HASH));
93
behavior_map.insert(std::pair<const std::string, memcached_behavior>
94
("MEMCACHED_BEHAVIOR_BINARY_PROTOCOL", MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
95
behavior_map.insert(std::pair<const std::string, memcached_behavior>
96
("MEMCACHED_BEHAVIOR_SND_TIMEOUT", MEMCACHED_BEHAVIOR_SND_TIMEOUT));
97
behavior_map.insert(std::pair<const std::string, memcached_behavior>
98
("MEMCACHED_BEHAVIOR_RCV_TIMEOUT", MEMCACHED_BEHAVIOR_RCV_TIMEOUT));
99
behavior_map.insert(std::pair<const std::string, memcached_behavior>
100
("MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT", MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT));
101
behavior_map.insert(std::pair<const std::string, memcached_behavior>
102
("MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK", MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK));
103
behavior_map.insert(std::pair<const std::string, memcached_behavior>
104
("MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK", MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK));
106
dist_settings_map.insert(std::pair<const std::string, uint64_t>
107
("MEMCACHED_DISTRIBUTION_MODULA", MEMCACHED_DISTRIBUTION_MODULA));
108
dist_settings_map.insert(std::pair<const std::string, uint64_t>
109
("MEMCACHED_DISTRIBUTION_CONSISTENT", MEMCACHED_DISTRIBUTION_CONSISTENT));
110
dist_settings_map.insert(std::pair<const std::string, uint64_t>
111
("MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA", MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA));
113
hash_settings_map.insert(std::pair<const std::string, uint64_t>
114
("MEMCACHED_HASH_DEFAULT", MEMCACHED_HASH_DEFAULT));
115
hash_settings_map.insert(std::pair<const std::string, uint64_t>
116
("MEMCACHED_HASH_MD5", MEMCACHED_HASH_MD5));
117
hash_settings_map.insert(std::pair<const std::string, uint64_t>
118
("MEMCACHED_HASH_CRC", MEMCACHED_HASH_CRC));
119
hash_settings_map.insert(std::pair<const std::string, uint64_t>
120
("MEMCACHED_HASH_FNV1_64", MEMCACHED_HASH_FNV1_64));
121
hash_settings_map.insert(std::pair<const std::string, uint64_t>
122
("MEMCACHED_HASH_FNV1A_64", MEMCACHED_HASH_FNV1A_64));
123
hash_settings_map.insert(std::pair<const std::string, uint64_t>
124
("MEMCACHED_HASH_FNV1_32", MEMCACHED_HASH_FNV1_32));
125
hash_settings_map.insert(std::pair<const std::string, uint64_t>
126
("MEMCACHED_HASH_FNV1A_32", MEMCACHED_HASH_FNV1A_32));
127
hash_settings_map.insert(std::pair<const std::string, uint64_t>
128
("MEMCACHED_HASH_JENKINS", MEMCACHED_HASH_JENKINS));
129
hash_settings_map.insert(std::pair<const std::string, uint64_t>
130
("MEMCACHED_HASH_HSIEH", MEMCACHED_HASH_HSIEH));
131
hash_settings_map.insert(std::pair<const std::string, uint64_t>
132
("MEMCACHED_HASH_MURMUR", MEMCACHED_HASH_MURMUR));
134
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
135
("MEMCACHED_HASH_DEFAULT", MEMCACHED_HASH_DEFAULT));
136
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
137
("MEMCACHED_HASH_MD5", MEMCACHED_HASH_MD5));
138
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
139
("MEMCACHED_HASH_CRC", MEMCACHED_HASH_CRC));
140
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
141
("MEMCACHED_HASH_FNV1_64", MEMCACHED_HASH_FNV1_64));
142
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
143
("MEMCACHED_HASH_FNV1A_64", MEMCACHED_HASH_FNV1A_64));
144
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
145
("MEMCACHED_HASH_FNV1_32", MEMCACHED_HASH_FNV1_32));
146
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
147
("MEMCACHED_HASH_FNV1A_32", MEMCACHED_HASH_FNV1A_32));
150
const char *func_name() const
152
return "memc_behavior_set";
155
String *val_str(String *);
157
void fix_length_and_dec()
163
void setFailureString(const char *error);
168
std::map<const std::string, memcached_behavior> behavior_map;
169
std::map<const std::string, uint64_t> dist_settings_map;
170
std::map<const std::string, uint64_t> hash_settings_map;
171
std::map<const std::string, uint64_t> ketama_hash_settings_map;
174
#endif /* DRIZZLE_PLUGIN_MEMCACHED_FUNCTIONS_MEMC_BEHAVIOR_SET_H */