Key Size

Boberg, Stefan Stefan.Boberg at dice.se
Sun Jan 7 18:58:54 UTC 2007


  You're wasting your time. Use a MD4 or MD5 hash and base64-encode the result and use as the key. The computational cost for calculating the hash will be lower than the time taken transmitting your key.

 

/Stefan

 

From: memcached-bounces at lists.danga.com [mailto:memcached-bounces at lists.danga.com] On Behalf Of Renato Silveira
Sent: 07 January 2007 15:05
To: Marc
Cc: memcached at lists.danga.com
Subject: Re: Key Size

 

Thank you all for the answers!
First of all I´ll try to increase the key size as Steve said. Because, the application that I´m working is perfomance oriented, so I think that we would have some problems with the overhead of Sha or MD5. 
I´m using java api of memcached as the client. The problem of whitespace in the url is solved because the client api use a URLEncoder in the key before the store the objects.
Well, as I´ll try this first approach and I tell you if it works! 

tks again!

Renato







On 1/5/07, Marc <Marc at facebook.com> wrote:

I misspoke about whitespace...the server will drop it, not the client.




On 1/5/07 11:25 AM, "Marc" <Marc at facebook.com> wrote:

	I see two possible problems.  First - as you note - the client needs to deal with the increase too.  I'm not sure which one you're using but for most implementations, the default read -buf  size for GET results is 250+1 so, if memcached is returning results like: 
	    VALUE very<250>long_key 0 3\r\nxxx\r\nEND 
	It very well may be the case that the client punts after scanning "VALUE very<250>" without seeing either space (\b) or CRLF (\r\n)
	
	Second, if you have spaces in your URL this will cause similar problems.  The client will take the following:
	    VALUE http://url/key/with white space 0 3\r\nxxx\r\nEND
	
	as the value for key "http://url/key/with" <http://url/key/with%C2%B2>  and not finding a corresponding client request for that key will  most likely discard it. 
	
	On 1/5/07 11:08 AM, "Renato Silveira" <renatosilveira at gmail.com> wrote:

	Hi,
	
	I´m using memcached as a URL keyword cache. The url is the key and the cached object is a string with relevant keywords of the site. Well, it´s working fine for my purpose. The only problem is the limit of key size to 250 bytes(because there can be url bigger than 250 bytes). Well, I tried to increase the value of the constant KEY_MAX_LENGTH to 2048 bytes. I recompile memcached and it´s not working. Should I have to make any modification on the client API? Does anyone can helpme with this issue? 
	
	tks!
	
	Renato

	 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20070107/fe919ae6/attachment.htm


More information about the memcached mailing list