net.spy.memcached.protocol.ascii.FlushOperationImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spymemcached Show documentation
Show all versions of spymemcached Show documentation
A client library for memcached.
// Copyright (c) 2006 Dustin Sallings
package net.spy.memcached.protocol.ascii;
import java.nio.ByteBuffer;
import net.spy.memcached.ops.FlushOperation;
import net.spy.memcached.ops.OperationCallback;
import net.spy.memcached.ops.OperationState;
import net.spy.memcached.ops.OperationStatus;
/**
* Memcached flush_all operation.
*/
final class FlushOperationImpl extends OperationImpl
implements FlushOperation {
private static final byte[] FLUSH="flush_all\r\n".getBytes();
private static final OperationStatus OK=
new OperationStatus(true, "OK");
private final int delay;
public FlushOperationImpl(int d, OperationCallback cb) {
super(cb);
delay=d;
}
@Override
public void handleLine(String line) {
getLogger().debug("Flush completed successfully");
getCallback().receivedStatus(matchStatus(line, OK));
transitionState(OperationState.COMPLETE);
}
@Override
public void initialize() {
ByteBuffer b=null;
if(delay == -1) {
b=ByteBuffer.wrap(FLUSH);
} else {
b=ByteBuffer.allocate(32);
b.put( ("flush_all " + delay + "\r\n").getBytes());
b.flip();
}
setBuffer(b);
}
@Override
public String toString() {
return "Cmd: flush_all Delay: " + delay;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy