00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #pragma once
00033
00034 #include <drizzled/item/func.h>
00035
00036 #include <libmemcached/memcached.h>
00037
00038 #include <map>
00039 #include <string>
00040
00041
00042 class MemcachedBehaviorSet : public drizzled::Item_str_func
00043 {
00044 public:
00045 MemcachedBehaviorSet()
00046 :
00047 Item_str_func(),
00048 failure_buff("0", &drizzled::my_charset_bin),
00049 success_buff("1", &drizzled::my_charset_bin),
00050 behavior_map(),
00051 dist_settings_map(),
00052 hash_settings_map(),
00053 ketama_hash_settings_map()
00054 {
00055 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00056 ("MEMCACHED_BEHAVIOR_SUPPORT_CAS", MEMCACHED_BEHAVIOR_SUPPORT_CAS));
00057 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00058 ("MEMCACHED_BEHAVIOR_NO_BLOCK", MEMCACHED_BEHAVIOR_NO_BLOCK));
00059 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00060 ("MEMCACHED_BEHAVIOR_TCP_NODELAY", MEMCACHED_BEHAVIOR_TCP_NODELAY));
00061 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00062 ("MEMCACHED_BEHAVIOR_HASH", MEMCACHED_BEHAVIOR_HASH));
00063 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00064 ("MEMCACHED_BEHAVIOR_CACHE_LOOKUPS", MEMCACHED_BEHAVIOR_CACHE_LOOKUPS));
00065 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00066 ("MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE", MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE));
00067 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00068 ("MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE", MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE));
00069 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00070 ("MEMCACHED_BEHAVIOR_BUFFER_REQUESTS", MEMCACHED_BEHAVIOR_BUFFER_REQUESTS));
00071 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00072 ("MEMCACHED_BEHAVIOR_KETAMA", MEMCACHED_BEHAVIOR_KETAMA));
00073 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00074 ("MEMCACHED_BEHAVIOR_POLL_TIMEOUT", MEMCACHED_BEHAVIOR_POLL_TIMEOUT));
00075 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00076 ("MEMCACHED_BEHAVIOR_RETRY_TIMEOUT", MEMCACHED_BEHAVIOR_RETRY_TIMEOUT));
00077 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00078 ("MEMCACHED_BEHAVIOR_DISTRIBUTION", MEMCACHED_BEHAVIOR_DISTRIBUTION));
00079 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00080 ("MEMCACHED_BEHAVIOR_USER_DATA", MEMCACHED_BEHAVIOR_USER_DATA));
00081 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00082 ("MEMCACHED_BEHAVIOR_SORT_HOSTS", MEMCACHED_BEHAVIOR_SORT_HOSTS));
00083 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00084 ("MEMCACHED_BEHAVIOR_VERIFY_KEY", MEMCACHED_BEHAVIOR_VERIFY_KEY));
00085 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00086 ("MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT", MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT));
00087 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00088 ("MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED", MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
00089 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00090 ("MEMCACHED_BEHAVIOR_KETAMA_HASH", MEMCACHED_BEHAVIOR_KETAMA_HASH));
00091 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00092 ("MEMCACHED_BEHAVIOR_BINARY_PROTOCOL", MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
00093 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00094 ("MEMCACHED_BEHAVIOR_SND_TIMEOUT", MEMCACHED_BEHAVIOR_SND_TIMEOUT));
00095 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00096 ("MEMCACHED_BEHAVIOR_RCV_TIMEOUT", MEMCACHED_BEHAVIOR_RCV_TIMEOUT));
00097 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00098 ("MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT", MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT));
00099 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00100 ("MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK", MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK));
00101 behavior_map.insert(std::pair<const std::string, memcached_behavior>
00102 ("MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK", MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK));
00103
00104 dist_settings_map.insert(std::pair<const std::string, uint64_t>
00105 ("MEMCACHED_DISTRIBUTION_MODULA", MEMCACHED_DISTRIBUTION_MODULA));
00106 dist_settings_map.insert(std::pair<const std::string, uint64_t>
00107 ("MEMCACHED_DISTRIBUTION_CONSISTENT", MEMCACHED_DISTRIBUTION_CONSISTENT));
00108 dist_settings_map.insert(std::pair<const std::string, uint64_t>
00109 ("MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA", MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA));
00110
00111 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00112 ("MEMCACHED_HASH_DEFAULT", MEMCACHED_HASH_DEFAULT));
00113 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00114 ("MEMCACHED_HASH_MD5", MEMCACHED_HASH_MD5));
00115 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00116 ("MEMCACHED_HASH_CRC", MEMCACHED_HASH_CRC));
00117 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00118 ("MEMCACHED_HASH_FNV1_64", MEMCACHED_HASH_FNV1_64));
00119 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00120 ("MEMCACHED_HASH_FNV1A_64", MEMCACHED_HASH_FNV1A_64));
00121 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00122 ("MEMCACHED_HASH_FNV1_32", MEMCACHED_HASH_FNV1_32));
00123 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00124 ("MEMCACHED_HASH_FNV1A_32", MEMCACHED_HASH_FNV1A_32));
00125 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00126 ("MEMCACHED_HASH_JENKINS", MEMCACHED_HASH_JENKINS));
00127 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00128 ("MEMCACHED_HASH_HSIEH", MEMCACHED_HASH_HSIEH));
00129 hash_settings_map.insert(std::pair<const std::string, uint64_t>
00130 ("MEMCACHED_HASH_MURMUR", MEMCACHED_HASH_MURMUR));
00131
00132 ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
00133 ("MEMCACHED_HASH_DEFAULT", MEMCACHED_HASH_DEFAULT));
00134 ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
00135 ("MEMCACHED_HASH_MD5", MEMCACHED_HASH_MD5));
00136 ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
00137 ("MEMCACHED_HASH_CRC", MEMCACHED_HASH_CRC));
00138 ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
00139 ("MEMCACHED_HASH_FNV1_64", MEMCACHED_HASH_FNV1_64));
00140 ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
00141 ("MEMCACHED_HASH_FNV1A_64", MEMCACHED_HASH_FNV1A_64));
00142 ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
00143 ("MEMCACHED_HASH_FNV1_32", MEMCACHED_HASH_FNV1_32));
00144 ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t>
00145 ("MEMCACHED_HASH_FNV1A_32", MEMCACHED_HASH_FNV1A_32));
00146 }
00147
00148 const char *func_name() const
00149 {
00150 return "memc_behavior_set";
00151 }
00152
00153 drizzled::String *val_str(drizzled::String *);
00154
00155 void fix_length_and_dec()
00156 {
00157 max_length= 32;
00158 }
00159
00160 private:
00161 void setFailureString(const char *error);
00162
00163 drizzled::String failure_buff;
00164 drizzled::String success_buff;
00165
00166 std::map<const std::string, memcached_behavior> behavior_map;
00167 std::map<const std::string, uint64_t> dist_settings_map;
00168 std::map<const std::string, uint64_t> hash_settings_map;
00169 std::map<const std::string, uint64_t> ketama_hash_settings_map;
00170 };
00171