Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ public FlushOperation flush(int delay, OperationCallback cb) {
return new FlushOperationImpl(delay, cb);
}

/**
* Get And Touch is only supported in memcached 1.5.3 and later.
*/
public GetAndTouchOperation getAndTouch(String key, int expiration,
GetAndTouchOperation.Callback cb) {
throw new UnsupportedOperationException("Get and touch is not supported "
+ "for ASCII protocol");
return new GetAndTouchOperationImpl(key, expiration, cb);
}

public GetOperation get(String key, GetOperation.Callback cb) {
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/net/spy/memcached/protocol/ascii/BaseGetOpImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,20 @@ public final void initialize() {
size += afterKeyBytesSize();
ByteBuffer b = ByteBuffer.allocate(size);
b.put(cmd.getBytes());
for (byte[] k : keyBytes) {
b.put((byte) ' ');
b.put(k);
if (cmd.equals("gats")) {
afterKeyBytes(b);
for (byte[] k : keyBytes) {
b.put((byte) ' ');
b.put(k);
}
}
else {
for (byte[] k : keyBytes) {
b.put((byte) ' ');
b.put(k);
}
afterKeyBytes(b);
}
afterKeyBytes(b);
b.put(RN_BYTES);
b.flip();
setBuffer(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,22 @@
public class GetAndTouchOperationImpl extends BaseGetOpImpl implements
GetAndTouchOperation {

private static final String CMD = "gats";

/**
* @deprecated use {@link #GetAndTouchOperationImpl(String, int,
* net.spy.memcached.ops.GetAndTouchOperation.Callback)}
*/
public GetAndTouchOperationImpl(String c, int e,
GetAndTouchOperation.Callback cb, String k) {
super(c, e, cb, k);
}

public GetAndTouchOperationImpl(String k, int e,
GetAndTouchOperation.Callback cb) {
super(CMD, e, cb, k);
}

@Override
public int getExpiration() {
return exp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testFlush() {
}

public void testGetAndTouch() {
(new GetAndTouchOperationImpl("gat", 15, null, "key")).toString();
(new GetAndTouchOperationImpl("key", 15, null)).toString();
}

public void testTouch() {
Expand Down