Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storehaus-memcache: pass ttl for MergeableMemcacheStore CAS calls #262

Merged
merged 3 commits into from
May 14, 2015

Conversation

franklinhu
Copy link
Contributor

MergeableMemcacheStore was not passing the right TTL setting, and thus was using the default of Time.epoch which never expires the item.

cc @danielhfrank

@danielhfrank
Copy link

@franklinhu we'll want to make the same adjustment to the call to add below

@franklinhu franklinhu force-pushed the franklin-memcache-fix branch from 2b6cd04 to fafa6d8 Compare May 12, 2015 03:38
@franklinhu
Copy link
Contributor Author

@danielhfrank Thanks, fixed in latest rev

@rubanm
Copy link
Contributor

rubanm commented May 12, 2015

Thanks for the fix! Will merge when green.

@@ -77,7 +77,7 @@ class MergeableMemcacheStore[K, V](underlying: MemcacheStore, maxRetries: Int)(k
inj.invert(cbValue) match {
case Success(v) => // attempt cas
val resV = semigroup.plus(v, kv._2)
underlying.client.cas(key, inj.apply(resV), casunique).flatMap { success =>
underlying.client.cas(key, 0, underlying.ttl.fromNow, inj.apply(resV), casunique).flatMap { success =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the second arg should be underlying.flag instead of 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what flag does, but this would change the existing behavior right? Should we also pass flags into CAS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found an explanation here
https://github.com/memcached/memcached/blob/master/doc/protocol.txt#L155
and here
http://stackoverflow.com/questions/12228097/what-is-the-flags-arg-in-finagle-memcached-set-method

The flag is opaque to the server and is returned back along with the value when reading. For correctness, it looks like we should set the same flag as the underlying store does for set calls. It's probably been working fine all this while because of the default being 0 in MemcacheStore. Not your change, but would be nice to fix this as well. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, didn't notice your latest rev. Should be added to the cas call as well I think.

@franklinhu
Copy link
Contributor Author

Fixed the review feedback. Looks like the test failures are unrelated to the memcache changes

@johnynek
Copy link
Collaborator

restarted the build.

@rubanm
Copy link
Contributor

rubanm commented May 14, 2015

Green now. Merging, thanks.

rubanm added a commit that referenced this pull request May 14, 2015
storehaus-memcache: pass ttl for MergeableMemcacheStore CAS calls
@rubanm rubanm merged commit d3585b5 into twitter:develop May 14, 2015
@franklinhu franklinhu deleted the franklin-memcache-fix branch May 14, 2015 16:48
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.

5 participants