*
*/
-#include "common.h"
+#include <libmemcached/common.h>
+#include <libmemcached/virtual_bucket.h>
+
#include <time.h>
#include <sys/types.h>
return memcached_behavior_set_key_hash(ptr, (memcached_hash_t)(data));
case MEMCACHED_BEHAVIOR_KETAMA_HASH:
return memcached_behavior_set_distribution_hash(ptr, (memcached_hash_t)(data));
+
case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS:
- ptr->flags.use_cache_lookups= set_flag(data);
- memcached_quit(ptr);
- break;
+ return memcached_set_error_string(ptr, MEMCACHED_DEPRECATED,
+ memcached_string_with_size("MEMCACHED_BEHAVIOR_CACHE_LOOKUPS has been deprecated."));
+
case MEMCACHED_BEHAVIOR_VERIFY_KEY:
if (ptr->flags.binary_protocol)
- return memcached_set_error_string(ptr, MEMCACHED_FAILURE,
+ return memcached_set_error_string(ptr, MEMCACHED_INVALID_ARGUMENTS,
memcached_string_with_size("MEMCACHED_BEHAVIOR_VERIFY_KEY if the binary protocol has been enabled."));
ptr->flags.verify_key= set_flag(data);
break;
memcached_quit(ptr);
break;
case MEMCACHED_BEHAVIOR_USER_DATA:
- return memcached_set_error_string(ptr, MEMCACHED_FAILURE,
+ return memcached_set_error_string(ptr, MEMCACHED_DEPRECATED,
memcached_string_with_size("MEMCACHED_BEHAVIOR_USER_DATA deprecated."));
case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY:
ptr->flags.hash_with_prefix_key= set_flag(data);
break;
case MEMCACHED_BEHAVIOR_CORK:
{
-#ifdef HAVE_MSG_MORE
- break;
-#else
- return memcached_set_error_string(ptr, MEMCACHED_NOT_SUPPORTED,
- memcached_string_with_size("MEMCACHED_BEHAVIOR_CORK is not supported on this platform."));
-#endif
+ return memcached_set_error_string(ptr, MEMCACHED_DEPRECATED,
+ memcached_string_with_size("MEMCACHED_BEHAVIOR_CORK is now incorporated into the driver by default."));
}
break;
case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE:
return ptr->flags.binary_protocol;
case MEMCACHED_BEHAVIOR_SUPPORT_CAS:
return ptr->flags.support_cas;
+
case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS:
- return ptr->flags.use_cache_lookups;
+ return true;
+
case MEMCACHED_BEHAVIOR_NO_BLOCK:
return ptr->flags.no_block;
case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS:
return (uint64_t) sock_size;
}
case MEMCACHED_BEHAVIOR_USER_DATA:
- return memcached_set_error_string(ptr, MEMCACHED_FAILURE,
- memcached_string_with_size("MEMCACHED_BEHAVIOR_USER_DATA deprecated."));
+ memcached_set_error_string(ptr, MEMCACHED_DEPRECATED,
+ memcached_string_with_size("MEMCACHED_BEHAVIOR_USER_DATA deprecated."));
+ return 0;
case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY:
return ptr->flags.hash_with_prefix_key;
case MEMCACHED_BEHAVIOR_NOREPLY:
case MEMCACHED_DISTRIBUTION_RANDOM: return "MEMCACHED_DISTRIBUTION_RANDOM";
case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: return "MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY";
case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: return "MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED";
+ case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: return "MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET";
default:
case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: return "INVALID memcached_server_distribution_t";
}
}
+
+memcached_return_t memcached_bucket_set(memcached_st *self,
+ const uint32_t *host_map,
+ const uint32_t *forward_map,
+ const uint32_t buckets,
+ const uint32_t replicas)
+{
+ memcached_return_t rc;
+
+ if (! self)
+ return MEMCACHED_INVALID_ARGUMENTS;
+
+ if (! host_map)
+ return MEMCACHED_INVALID_ARGUMENTS;
+
+ memcached_server_distribution_t old;
+ old= memcached_behavior_get_distribution(self);
+
+ rc =memcached_behavior_set_distribution(self, MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET);
+ if (rc != MEMCACHED_SUCCESS)
+ {
+ return rc;
+ }
+
+ rc= memcached_virtual_bucket_create(self, host_map, forward_map, buckets, replicas);
+ if (rc != MEMCACHED_SUCCESS)
+ {
+ memcached_behavior_set_distribution(self, old);
+ }
+
+ return rc;
+}