Description:
------------
Currently, when a key is invalid, the get method/function simply returns false. It would be nice if either an E_WARNING or E_NOTICE was thrown when a key is not a valid memcached key
Reproduce code:
---------------
$m = new Memcached();
$res = $m->addServer("localhost", 11211);
$res = $m->set("this is a key with spaces", 1);
Expected result:
----------------
E_WARNING or E_NOTICE
Actual result:
--------------
No error is thrown.

Patches

Pull Requests

History

You can use getResultCode() to check the result of the operation. Currently it returns Memcached::RES_PROTOCOL_ERROR for bad keys. I can add an option Memcached::OPT_VERIFY_KEYS that would validate all keys on every operation and return Memcached::RES_BAD_KEY_PROVIDED in case one of the keys is bad.d

[2009-06-26 18:41 UTC] marc dot bennewitz at giata dot de

The memcache extension allows all strings to use as key. Is it possible to handle this same with this memcached exception ?
What is a list of rules for it ?

I don't understand what you mean by "is it possible to handle this same with this memcached exception". Can you try asking again?

[2009-06-26 18:56 UTC] marc dot bennewitz at giata dot de

On memcache it works fine to use special chars for cache ids:
$memcache->set("id &% \/\$\x00\t\n\r\\", 'data', 0, 100);
var_dump($memcache->get("id &% \/\$\x00\t\n\r\\"));
But on memcached the same code generates a Memcached::RES_BAD_KEY_PROVIDED.
It would be very nice if memcached will handle all characters as keys in the future?

[2009-09-12 06:34 UTC] Jared dot Williams1 at ntlworld dot com

"What is a list of rules for it ?"
Keys have made up of characters that satisfy C's isgraph().