Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an operation to reset the expiration time of a key. I have tested this code thoughly and will check in the unit tests in a later commit. Change-Id: Iee3045bdb58142dd44c9e8c723dffe7abdbcb230 Reviewed-on: http://review.couchbase.org/6753 Tested-by: Michael Wiederhold <mike@couchbase.com> Reviewed-by: Matt Ingenthron <matt@couchbase.com>
- Loading branch information
Mike Wiederhold
authored and
Michael Wiederhold
committed
Jun 4, 2011
1 parent
2ed6c31
commit 646de49
Showing
5 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/net/spy/memcached/protocol/binary/TouchOperationImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package net.spy.memcached.protocol.binary; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import net.spy.memcached.ops.KeyedOperation; | ||
import net.spy.memcached.ops.OperationCallback; | ||
import net.spy.memcached.ops.OperationStatus; | ||
|
||
/** | ||
* Operation to reset a timeout in Membase server. | ||
*/ | ||
public class TouchOperationImpl extends OperationImpl | ||
implements KeyedOperation { | ||
|
||
static final int CMD=28; | ||
|
||
private final String key; | ||
private final int exp; | ||
|
||
protected TouchOperationImpl(String k, int e, OperationCallback cb) { | ||
super(CMD, generateOpaque(), cb); | ||
key=k; | ||
exp=e; | ||
} | ||
|
||
@Override | ||
public Collection<String> getKeys() { | ||
return Collections.singleton(key); | ||
} | ||
|
||
@Override | ||
protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) { | ||
OperationStatus baseStatus = super.getStatusForErrorCode(errCode, errPl); | ||
if (baseStatus != null) { | ||
return baseStatus; | ||
} | ||
OperationStatus rv=null; | ||
switch(errCode) { | ||
case ERR_EXISTS: | ||
rv=EXISTS_STATUS; | ||
break; | ||
case ERR_NOT_FOUND: | ||
rv=NOT_FOUND_STATUS; | ||
break; | ||
case ERR_TEMP_FAIL: | ||
rv=TEMP_FAIL; | ||
break; | ||
} | ||
return rv; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
prepareBuffer(key, 0, EMPTY_BYTES, exp); | ||
} | ||
|
||
} |