MEM_TCP_NODELAY= (1 << 1),
MEM_REUSE_MEMORY= (1 << 2),
MEM_USE_MD5= (1 << 3),
+ MEM_USE_KETAMA= (1 << 4),
} memcached_flags;
void md5_signature(unsigned char *key, unsigned int length, unsigned char *result);
memcached_behavior flag,
void *data)
{
+ memcached_flags temp_flag;
+
switch (flag)
{
case MEMCACHED_BEHAVIOR_NO_BLOCK:
- {
- unsigned int *truefalse= (unsigned int *)data;
- memcached_quit(ptr);
- if (truefalse)
- ptr->flags|= MEM_NO_BLOCK;
- else
- ptr->flags+= MEM_NO_BLOCK;
- break;
- }
-
+ temp_flag= MEM_NO_BLOCK;
case MEMCACHED_BEHAVIOR_TCP_NODELAY:
+ temp_flag= MEM_TCP_NODELAY;
+ case MEMCACHED_BEHAVIOR_MD5_HASHING:
+ temp_flag= MEM_USE_MD5;
+ case MEMCACHED_BEHAVIOR_KETAMA:
+ temp_flag= MEM_USE_KETAMA;
{
unsigned int *truefalse= (unsigned int *)data;
memcached_quit(ptr);
if (truefalse)
- ptr->flags|= MEM_TCP_NODELAY;
+ ptr->flags|= temp_flag;
else
- ptr->flags+= MEM_TCP_NODELAY;
+ ptr->flags+= temp_flag;
break;
}
-
- case MEMCACHED_BEHAVIOR_MD5_HASHING:
- ptr->flags+= MEM_USE_MD5;
- break;
}
return MEMCACHED_SUCCESS;
unsigned long long memcached_behavior_get(memcached_st *ptr,
memcached_behavior flag)
{
+ memcached_flags temp_flag;
+
switch (flag)
{
case MEMCACHED_BEHAVIOR_NO_BLOCK:
- if (ptr->flags & MEM_NO_BLOCK)
- return 1;
- else
- return 0;
+ temp_flag= MEM_NO_BLOCK;
case MEMCACHED_BEHAVIOR_TCP_NODELAY:
- if (ptr->flags & MEM_TCP_NODELAY)
- return 1;
- else
- return 0;
+ temp_flag= MEM_TCP_NODELAY;
case MEMCACHED_BEHAVIOR_MD5_HASHING:
- if (ptr->flags & MEM_USE_MD5)
+ temp_flag= MEM_USE_MD5;
+ case MEMCACHED_BEHAVIOR_KETAMA:
+ temp_flag= MEM_USE_KETAMA;
+ if (ptr->flags & temp_flag)
return 1;
else
return 0;
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY);
assert(value == 1);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_MD5_HASHING, &set);
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_MD5_HASHING);
+ assert(value == 1);
+
set= 0;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, &set);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, &set);
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY);
assert(value == 0);
+
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_MD5_HASHING, &set);
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_MD5_HASHING);
+ assert(value == 0);
}
void add_host_test1(memcached_st *memc)