Package net.spy.memcached.protocol.binary

Source Code of net.spy.memcached.protocol.binary.DeleteOperationImpl

package net.spy.memcached.protocol.binary;

import java.util.Collection;
import java.util.Collections;

import net.spy.memcached.ops.DeleteOperation;
import net.spy.memcached.ops.OperationCallback;
import net.spy.memcached.ops.OperationStatus;

class DeleteOperationImpl extends OperationImpl implements
    DeleteOperation {

  private static final int CMD=4;

  private final String key;
  private final long cas;

  public DeleteOperationImpl(String k, OperationCallback cb) {
    this(k, 0, cb);
  }

  public DeleteOperationImpl(String k, long c, OperationCallback cb) {
    super(CMD, generateOpaque(), cb);
    key=k;
    cas=c;
  }

  @Override
  public void initialize() {
    prepareBuffer(key, cas, EMPTY_BYTES);
  }

  @Override
  protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) {
        OperationStatus baseStatus = super.getStatusForErrorCode(errCode, errPl);
        if (baseStatus != null) {
            return baseStatus;
        }
    return errCode == ERR_NOT_FOUND ? NOT_FOUND_STATUS : null;
  }

  public Collection<String> getKeys() {
    return Collections.singleton(key);
  }

}
TOP

Related Classes of net.spy.memcached.protocol.binary.DeleteOperationImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.