WebFaction
Community site: login faq
0
1

I have four large objects that I'm caching using Memcached. I've allocated 200MB to Memcached.

In my Python code, I cache the items like so:

cache.set('object_1', object1)  # fourth biggest in size
cache.set('object_2', object2)  # second biggest in size
cache.set('object_3', object3)  # third biggest in size
cache.set('object_4', object4)  # biggest in size

In my cache, I have access to object_1 and object_3 but not object_2 and object_4 - Is Memcached making a call on its own as to which objects to cache and which to ignore based on the available memory?

asked 02 Nov '12, 13:23

aa56280
1311014
accept rate: 0%


There's a good explanation of this here: Memcache Internals

"As you might already know, memcache will delete old data to make room for your new data, but it needs to know which data-object can be deleted. Is it the largest one so we instantly have a lot of room? Or maybe it’s the first one entered, so you get a FIFO based caching system? Turns out, memcache uses a much more advanced technique called LRU: Least Recently Used. In a nutshell: it deletes the item that isn’t used for the longest period of time. This doesn’t have to be the largest object though. And it even doesn’t have to be the first object stored in the cache."

Hope that helps!

permanent link

answered 02 Nov '12, 13:29

seanf
12.2k42136
accept rate: 37%

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:

×910
×337

question asked: 02 Nov '12, 13:23

question was seen: 3,001 times

last updated: 02 Nov '12, 13:29

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2020 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