what is the maximum of memcached key size now ?

17,269 views
Skip to first unread message

pdah

unread,
Apr 26, 2009, 6:22:07 AM4/26/09
to memcached
Hi everybody,
As far as I know the maximum key size for an item in memcached is 250
and can be extended to 255. I've just installed the lastest version of
memcached on my Ubuntu and tried to set an item with length of 300 and
600. I was surprise that it was set correctly, even using get/set
command, C/C++ library libmemcached or memcached extension of PHP.
I checked the source code, in memcached.h :
typedef struct _stritem {
.................
uint8_t nkey; /* key length, w/terminating null and
padding */
................
} item;

the type of key length is still uint8_t which is 1 byte, how can it
manage with key length 300 and 600 ?

Syed Ali

unread,
Apr 26, 2009, 11:19:39 AM4/26/09
to memc...@googlegroups.com
Did you just put an item with that 300 chars key and got it back. If
so, it could have been truncated to 255 and since you didnt submit
another item with the same first 255 chars in the key, you got it
back...

Makes sense?


Regards,
Zer0frequency


--
Best,
- Ali

Huy Phan

unread,
Apr 26, 2009, 11:45:53 AM4/26/09
to memc...@googlegroups.com
I wrote a PHP script to test my memcached. What I did is that setting
100 000 items (that have 10 different values) , then get them back and
check if the values are correct or not.
You can check the script at :
http://pastebin.com/fb443de3

All the items I got back are correct after I run this script.

Huy Phan

unread,
Apr 26, 2009, 1:53:20 PM4/26/09
to memc...@googlegroups.com
Sorry please ignore my last message,
it was going wrong, what i set was the value, not the key

Brian Moon

unread,
Apr 26, 2009, 11:59:29 PM4/26/09
to memc...@googlegroups.com
pecl/memcache will handle your keys being too long. I forget what it
does (md5 maybe) but it silently deals with it.


Brian.
--------
http://brian.moonspot.net/

Reply all
Reply to author
Forward
0 new messages