Question

acoording to documentation memcache unit can have a max lifetime of one month unless it is deleted due to servers ram capacity problems.

my app stores {'customer_id':'customer_name'} in memcache (1600+ items), which is used for autocomplete and customer index needs.

heres the code:

memcache.add('keys', keys, time=86400) #if 'keys' is absent, then all memcache items are regenerated.
memcache.add_multi(names, time=86500, key_prefix='customer_id_')

The problem is that most of my entries expire in an hour or so, leaving only 10 or 11 items. docs also say that if time is not set, the default life time of memcache item is one hour.

So did i set life cycle of memcache incorectly (if so, why does it leave 10 items) or is google memcache this unreliable for 11+ items (what should i do in this case? store this data in XML somehow?)?

Was it helpful?

Solution

Current stats for my quiet app show it can easily hold hundreds of items for several hours:

Item count:         285 item(s)
Total cache size:   5462609 byte(s)
Oldest item age:    11 hour(s) 38 min(s) 29 second(s)

If you have 1600 items and one item (key+data) size is less than 500 bytes, I'd recommend to store them all in one single memcache entry as a dictionary or something.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top