-0.17
- * More error messages on command line tools.
-
0.16
* Work on the UDP protocol
* Added get_by_key, set_by_key tests for C++ API
clients with the same lists, will have same distribution. (Idea from
Ross McFarland). MEMCACHED_BEHAVIOR_SORT_HOSTS was added to enable
this support.
- * Added MEMCACHED_BAD_KEY_PROVIDED error for auto, set, and get operations
- when the library is compiled with --enable-debug. This additional code
- will test for bad keys.
+ * Added MEMCACHED_BAD_KEY_PROVIDED error for auto, set, and get operations.
+ MEMCACHED_BEHAVIOR_VERIFY_KEY was added to enable this feature.
+ * More error messages on command line tools.
0.15 Tue Jan 29 14:55:44 PST 2008
* More work on the C++ API.
connection. Quiting the connection or closing down the connection will also
cause the buffered data to be pushed to the remote connection.
+=item MEMCACHED_BEHAVIOR_VERIFY_KEY
+
+Enabling this will cause libmemcached(3) to test all keys to verify that they
+are valid keys.
+
=item MEMCACHED_BEHAVIOR_SORT_HOSTS
Enabling this will cause hosts that are added to be placed in the host list in
MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,
MEMCACHED_BEHAVIOR_USER_DATA,
MEMCACHED_BEHAVIOR_SORT_HOSTS,
+ MEMCACHED_BEHAVIOR_VERIFY_KEY,
} memcached_behavior;
typedef enum {
MEM_SUPPORT_CAS= (1 << 7),
MEM_BUFFER_REQUESTS= (1 << 8),
MEM_USE_SORT_HOSTS= (1 << 9),
+ MEM_VERIFY_KEY= (1 << 10),
} memcached_flags;
/* Hashing algo */
memcached_result_st *result);
void server_list_free(memcached_st *ptr, memcached_server_st *servers);
-memcached_return key_proof(char **keys, size_t *key_length,
- unsigned int number_of_keys);
-
-#ifdef HAVE_DEBUG
-#define key_test(A,B,C) key_proof(A,B,C)
-#else
-#define key_test(A,B,C) MEMCACHED_SUCCESS
-#endif
+memcached_return memcachd_key_test(char **keys, size_t *key_length,
+ unsigned int number_of_keys);
#endif /* __COMMON_H__ */
if (ptr->hosts == NULL || ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
- if (key_test(&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED)
+ if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test(&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
return MEMCACHED_BAD_KEY_PROVIDED;
server_key= memcached_generate_hash(ptr, key, key_length);
void set_behavior_flag(memcached_st *ptr, memcached_flags temp_flag, void *data)
{
- unsigned int *truefalse= (unsigned int *)data;
+ unsigned int truefalse= *(unsigned int *)data;
memcached_quit(ptr);
if (truefalse)
case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS:
set_behavior_flag(ptr, MEM_USE_CACHE_LOOKUPS, data);
break;
+ case MEMCACHED_BEHAVIOR_VERIFY_KEY:
+ set_behavior_flag(ptr, MEM_VERIFY_KEY, data);
+ break;
case MEMCACHED_BEHAVIOR_KETAMA:
set_behavior_flag(ptr, MEM_USE_KETAMA, data);
break;
case MEMCACHED_BEHAVIOR_TCP_NODELAY:
temp_flag= MEM_TCP_NODELAY;
break;
+ case MEMCACHED_BEHAVIOR_VERIFY_KEY:
+ temp_flag= MEM_VERIFY_KEY;
+ break;
case MEMCACHED_BEHAVIOR_DISTRIBUTION:
return ptr->distribution;
case MEMCACHED_BEHAVIOR_HASH:
break;
case MEMCACHED_BEHAVIOR_USER_DATA:
return 0;
- //return (unsigned long long)ptr->user_data;
case MEMCACHED_BEHAVIOR_POLL_TIMEOUT:
{
return (unsigned long long)ptr->poll_timeout;
if (ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
- if (key_test(keys, key_length, number_of_keys) == MEMCACHED_BAD_KEY_PROVIDED)
+ if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test(keys, key_length, number_of_keys) == MEMCACHED_BAD_KEY_PROVIDED))
return MEMCACHED_BAD_KEY_PROVIDED;
if (ptr->flags & MEM_SUPPORT_CAS)
if (ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
- if (key_test(&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED)
+ if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test(&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
return MEMCACHED_BAD_KEY_PROVIDED;
server_key= memcached_generate_hash(ptr, master_key, master_key_length);
uint8_t bad_key_test(memcached_st *memc)
{
-#ifdef HAVE_DEBUG
memcached_return rc;
char *key= "foo bad";
char *string;
size_t string_length;
uint32_t flags;
+ memcached_st *clone;
+ unsigned int set= 1;
- string= memcached_get(memc, key, strlen(key),
+ clone= memcached_clone(NULL, memc);
+ assert(clone);
+
+ (void)memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, &set);
+
+ string= memcached_get(clone, key, strlen(key),
&string_length, &flags, &rc);
assert(rc == MEMCACHED_BAD_KEY_PROVIDED);
assert(string_length == 0);
assert(!string);
-#endif
+
+ set= 0;
+ (void)memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, &set);
+ string= memcached_get(clone, key, strlen(key),
+ &string_length, &flags, &rc);
+ assert(rc == MEMCACHED_NOTFOUND);
+ assert(string_length == 0);
+ assert(!string);
+
+ memcached_free(clone);
return 0;
}