Issue
I know that entries in memcached have a length limitation by default is 1M. And this value is configurable by passing -I
when starting the daemon. When I write my client, I want to protect my user from passing in values that are too large to fit in. I run some tests and found there is a 71 bytes
margin on my machine between the item_size_max and key_length+value_lenght.
I have STAT item_size_max 1048576
as default,
I put in byte[] key = new byte[250]; byte[] value = new byte[1048255];
success, and 1048576-250-1048255 =71
I put in byte[] key = new byte[250]; byte[] value = new byte[1048256];
failed.
Tried with multiple total cache size, multiple max item size limitation and multiple key lengths. There is always a 71 bytes margin between the sum of the length of my key and value and the item_size_max.
I am wondering how can I figure out what is the longest value I can put in, instead of the length of the entry.
Cheers! Thanks in advance.
Solution
Got respond from github/memcached issues
https://github.com/memcached/memcached/issues/334
In short
- there's a "./sizes" utility built which describes the overhead of various data structures.
- A simple approach could be like setting max size to 1M - 2x the maximum key length (500).
Answered By - JasonShao Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.