login community faq

Hello everyone! I'm making a Django website for language learning. I need to put about 100K key/value pairs in a in-memory-cache (that I will find a way to make persistent). I've followed the guide to install python-memcached here. When let Django read my dictionary and enter the key/value pairs, random lookups of words that should be in the dictionary are not found. I also hardcoded one key value pair using this code:

cache.set('foreignword', 'translation', 999999)

... which works. But when I enter this key/value pair into memcached BEFORE the dictionary entries, it cannot be found. This leads me to believe that I've exceeded the maximum allowed number of entries. How can I increase it?

Thank you

asked Jun 07 '12 at 06:57

sterneberg's gravatar image

sterneberg
112


I don't believe there is a hard-coded maximum number of entries (keys) in memcached. Rather, you specify a certain amount of memory, and then if you commit new entries such that the allocated memory is exceeded, old entries are discarded to make room. This stackoverflow post corroborates.

The amount of memory to allocated is specified by the -m command-line option when starting memcached. Note that 40MB of data will not fit in a 40MB (total) memcache; there is significant memory overhead in maintaining the internal hash table, and the greater number of keys, the greater the overhead.

Hope that helps!

answered Jun 07 '12 at 19:54

ryans's gravatar image

ryans ♦♦
28011420

This was very helpful, thank you! I worked around the problem, not using memcached as a persistent storage.

(Jun 10 '12 at 22:05) sterneberg sterneberg's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×641
×27
×1

Asked: Jun 07 '12 at 06:57

Seen: 452 times

Last updated: Jun 10 '12 at 22:05

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited