[SPY-69] CASMutator expiration doesn't work properly. Created: 04/Jan/12  Updated: 22/Jan/12  Resolved: 22/Jan/12

Status: Resolved
Project: Spymemcached Java Client
Component/s: library
Affects Version/s: 2.7.3
Fix Version/s: 2.8.0
Security Level: Public

Type: Bug Priority: Major
Reporter: Mike Wiederhold Assignee: Mike Wiederhold
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment: All

Team, got a customer saying that the CAS operation within spy 2.7.3 doesn't seem to reset the expiration of a key properly.

Here's a snippet of code:

public String updateVsSession(String key, final String session) throws Exception {

MemcachedClient sessionClient = cachePool.getConnection(PersistableBeanType.VS_SESSION);

Transcoder tc = new SerializingTranscoder();

CASMutator<String> mutator = new CASMutator<String>(sessionClient, tc);

CASMutation<String> mutation = new CASMutation<String>() {

public String getNewValue(String current) {

return session;



return mutator.cas(key, session, 1900, mutation);


It appears that when running the CAS operation only once, the key expires as expected. However, if an update is made and the operation is run again, the key seems to last forever.

Can you confirm whether this is a bug or expected? The customer expects that the CAS operation would constantly "extend" the expiration time.

Comment by Mike Wiederhold [ 04/Jan/12 ]
From bug fix commit message:

The cas call in this class wasn't using the function that allows
the expiration to be specified. As a result, if the CASMutator was
used and an item was already in memcached then the expiration would
be set to 0.
Comment by Perry Krug [ 17/Jan/12 ]
If this is fixed, can we mark it as resolved?
Generated at Thu Nov 27 17:06:09 CST 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.