| 1 | package net.spy.memcached.protocol.binary; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.Collections; |
| 5 | |
| 6 | import net.spy.memcached.ops.DeleteOperation; |
| 7 | import net.spy.memcached.ops.OperationCallback; |
| 8 | import net.spy.memcached.ops.OperationStatus; |
| 9 | |
| 10 | class DeleteOperationImpl extends OperationImpl implements |
| 11 | DeleteOperation { |
| 12 | |
| 13 | private static final int CMD=4; |
| 14 | |
| 15 | private final String key; |
| 16 | private final long cas; |
| 17 | |
| 18 | public DeleteOperationImpl(String k, OperationCallback cb) { |
| 19 | this(k, 0, cb); |
| 20 | } |
| 21 | |
| 22 | public DeleteOperationImpl(String k, long c, OperationCallback cb) { |
| 23 | super(CMD, generateOpaque(), cb); |
| 24 | key=k; |
| 25 | cas=c; |
| 26 | } |
| 27 | |
| 28 | @Override |
| 29 | public void initialize() { |
| 30 | prepareBuffer(key, cas, EMPTY_BYTES); |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) { |
| 35 | return errCode == ERR_NOT_FOUND ? NOT_FOUND_STATUS : null; |
| 36 | } |
| 37 | |
| 38 | public Collection<String> getKeys() { |
| 39 | return Collections.singleton(key); |
| 40 | } |
| 41 | |
| 42 | } |