WebFaction
Community site: login 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 07 Jun '12, 06:57

sterneberg
1124
accept rate: 0%


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!

permanent link

answered 07 Jun '12, 19:54

ryans ♦♦
5.0k93160
accept rate: 43%

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

(10 Jun '12, 22:05) sterneberg
Your answer
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

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×908
×34
×1

question asked: 07 Jun '12, 06:57

question was seen: 2,811 times

last updated: 10 Jun '12, 22:05

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM