Skip to content

Use default time if none set, use 0 to set no timeout (just like memcached)#20

Open
meconlin wants to merge 2 commits into
pamelafox:masterfrom
meconlin:defaultttl
Open

Use default time if none set, use 0 to set no timeout (just like memcached)#20
meconlin wants to merge 2 commits into
pamelafox:masterfrom
meconlin:defaultttl

Conversation

@meconlin

Copy link
Copy Markdown

I added a default time to live of 5 minutes.

If a user wants no time to live then you can send a time value of 0 (this is how memcached does it).

If part of your application is not setting the optional time argument but another part of the application is then when the cache gets full only the items with times are considered for eviction. The result is you are not really evicting by recency, simply due to one dev leaving off an optional param and the other deciding to use it.

I believe having to explicitly set an item as forever ttl is better behavior (this is how memcached does it).

Tests added and all existing still pass.

@pamelafox

Copy link
Copy Markdown
Owner

Hm, interesting! I based this off the Python memcached client (https://developers.google.com/appengine/docs/python/memcache/clientclass#Client_set) where the default is never expire, because the default for the named argument is 0. The PHP memcached client seems to do the same thing. Which memcached library defaults to 5 minutes?

@meconlin

Copy link
Copy Markdown
Author

My setting the default to five minutes was arbitrary and I didnt mean to imply that was the memcached default. I simply meant that sending 0 explicitly to make the ttl forever is the memcache way.

As it stands now a lazy developer will use up the cache hurting performance of anything cached with the more explicit option. That seems backwards to me and caused some problems for me at work.

I think if you want no ttl and thus no possibility of eviction you should have to explicitly ask for that. The default when nothing is sent can be whatever, 5 minutes just works well for our very busy site.

Let me know if I am not making sense. Other clients that are actually using memcached dont have the very tight memory constraints that a browser cache has, so the issue of some sets with forever clogging up the system rarely come up.

Thanks,
Mark

EDIT:
From memcached docs
http://code.google.com/p/memcached/wiki/NewProgramming#set

"Expiration times can be set from 0, meaning "never expire", to 30 days."
.... but the point is that a timeout is required.

On Oct 21, 2013, at 2:14 PM, Pamela Fox notifications@github.com wrote:

Hm, interesting! I based this off the Python memcached client (https://developers.google.com/appengine/docs/python/memcache/clientclass#Client_set) where the default is never expire, because the default for the named argument is 0. The PHP memcached client seems to do the same thing. Which memcached library defaults to 5 minutes?


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants