Skip to content

Commit b609da4

Browse files
committed
Remove support for hold values on deletes.
This functionality was removed after we all agreed it was confusing as 1157f3c5ce25918558781bd2207b6b6de702dd17 in memcached by Trond Norbye (merged in by Toru). Mon Jul 28 17:55:41 2008 +0900 That ID will probably be killed off by a rebase.
1 parent 8262a2a commit b609da4

8 files changed

Lines changed: 27 additions & 60 deletions

File tree

‎src/main/java/net/spy/memcached/MemcachedClient.java‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,12 +1145,24 @@ public long decr(String key, int by, long def)
11451145
*
11461146
* @param key the key to delete
11471147
* @param hold how long the key should be unavailable to add commands
1148+
*
1149+
* @deprecated Hold values are no longer honored.
11481150
*/
1151+
@Deprecated
11491152
public Future<Boolean> delete(String key, int hold) {
1153+
return delete(key);
1154+
}
1155+
1156+
/**
1157+
* Delete the given key from the cache.
1158+
*
1159+
* @param key the key to delete
1160+
*/
1161+
public Future<Boolean> delete(String key) {
11501162
final CountDownLatch latch=new CountDownLatch(1);
11511163
final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
11521164
operationTimeout);
1153-
DeleteOperation op=opFact.delete(key, hold,
1165+
DeleteOperation op=opFact.delete(key,
11541166
new OperationCallback() {
11551167
public void receivedStatus(OperationStatus s) {
11561168
rv.set(s.isSuccess());
@@ -1163,13 +1175,6 @@ public void complete() {
11631175
return rv;
11641176
}
11651177

1166-
/**
1167-
* Shortcut to delete that doesn't put a hold on the key.
1168-
*/
1169-
public Future<Boolean> delete(String key) {
1170-
return delete(key, 0);
1171-
}
1172-
11731178
/**
11741179
* Flush all caches from all servers with a delay of application.
11751180
*/

‎src/main/java/net/spy/memcached/MemcachedClientIF.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package net.spy.memcached;
22

3-
import net.spy.memcached.transcoders.Transcoder;
4-
53
import java.net.SocketAddress;
64
import java.util.Collection;
75
import java.util.Map;
86
import java.util.concurrent.Future;
97
import java.util.concurrent.TimeUnit;
108

9+
import net.spy.memcached.transcoders.Transcoder;
10+
1111
/**
1212
* This interface is provided as a helper for testing clients of the MemcachedClient.
1313
*/
@@ -114,8 +114,6 @@ long incr(String key, int by, long def)
114114
long decr(String key, int by, long def)
115115
throws OperationTimeoutException;
116116

117-
Future<Boolean> delete(String key, int hold);
118-
119117
Future<Boolean> delete(String key);
120118

121119
Future<Boolean> flush(int delay);

‎src/main/java/net/spy/memcached/OperationFactory.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ public interface OperationFactory {
3535
* Create a deletion operation.
3636
*
3737
* @param key the key to delete
38-
* @param when the locking duration
3938
* @param operationCallback the status callback
4039
* @return the new DeleteOperation
4140
*/
42-
DeleteOperation delete(String key, int when,
43-
OperationCallback operationCallback);
41+
DeleteOperation delete(String key, OperationCallback operationCallback);
4442

4543
/**
4644
* Create a flush operation.

‎src/main/java/net/spy/memcached/protocol/ascii/AsciiOperationFactory.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
*/
2525
public final class AsciiOperationFactory implements OperationFactory {
2626

27-
public DeleteOperation delete(String key, int when,
28-
OperationCallback cb) {
29-
return new DeleteOperationImpl(key, when, cb);
27+
public DeleteOperation delete(String key, OperationCallback cb) {
28+
return new DeleteOperationImpl(key, cb);
3029
}
3130

3231
public FlushOperation flush(int delay, OperationCallback cb) {

‎src/main/java/net/spy/memcached/protocol/ascii/DeleteOperationImpl.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ final class DeleteOperationImpl extends OperationImpl
2424
new OperationStatus(false, "NOT_FOUND");
2525

2626
private final String key;
27-
private final int when;
2827

29-
public DeleteOperationImpl(String k, int w, OperationCallback cb) {
28+
public DeleteOperationImpl(String k, OperationCallback cb) {
3029
super(cb);
3130
key=k;
32-
when=w;
3331
}
3432

3533
@Override
@@ -43,7 +41,7 @@ public void handleLine(String line) {
4341
public void initialize() {
4442
ByteBuffer b=ByteBuffer.allocate(
4543
KeyUtil.getKeyBytes(key).length + OVERHEAD);
46-
setArguments(b, "delete", key, when);
44+
setArguments(b, "delete", key);
4745
b.flip();
4846
setBuffer(b);
4947
}

‎src/main/java/net/spy/memcached/protocol/binary/BinaryOperationFactory.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
*/
2626
public class BinaryOperationFactory implements OperationFactory {
2727

28-
public DeleteOperation delete(String key, int when,
29-
OperationCallback operationCallback) {
30-
return new DeleteOperationImpl(key, when, operationCallback);
28+
public DeleteOperation delete(String key,
29+
OperationCallback operationCallback) {
30+
return new DeleteOperationImpl(key, operationCallback);
3131
}
3232

3333
public FlushOperation flush(int delay, OperationCallback cb) {

‎src/main/java/net/spy/memcached/protocol/binary/DeleteOperationImpl.java‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@ class DeleteOperationImpl extends OperationImpl implements
1010
private static final int CMD=4;
1111

1212
private final String key;
13-
private final int when;
1413
private final long cas;
1514

16-
public DeleteOperationImpl(String k, int w, OperationCallback cb) {
17-
this(k, w, 0, cb);
15+
public DeleteOperationImpl(String k, OperationCallback cb) {
16+
this(k, 0, cb);
1817
}
1918

20-
public DeleteOperationImpl(String k, int w, long c, OperationCallback cb) {
19+
public DeleteOperationImpl(String k, long c, OperationCallback cb) {
2120
super(CMD, generateOpaque(), cb);
2221
key=k;
23-
when=w;
2422
cas=c;
2523
}
2624

2725
@Override
2826
public void initialize() {
29-
prepareBuffer(key, cas, EMPTY_BYTES, when);
27+
prepareBuffer(key, cas, EMPTY_BYTES);
3028
}
3129

3230
@Override

‎src/test/java/net/spy/memcached/ProtocolBaseCase.java‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -407,35 +407,6 @@ public void testImmediateDelete() throws Exception {
407407
assertNull(client.get("test1"));
408408
}
409409

410-
public void testDeleteFuture() throws Exception {
411-
String key="deleteFuture";
412-
assertNull(client.get(key));
413-
client.set(key, 5, "test1value");
414-
assertEquals("test1value", client.get(key));
415-
Future<Boolean> f=client.delete(key);
416-
assertNull(client.get(key));
417-
assertTrue("Deletion didn't return true", f.get());
418-
assertFalse("Second deletion returned true",
419-
client.delete(key).get());
420-
}
421-
422-
public void testDelayedDelete() throws Exception {
423-
assertNull(client.get("test1"));
424-
client.set("test1", 5, "test1value");
425-
assertEquals("test1value", client.get("test1"));
426-
client.delete("test1", 5);
427-
assertNull(client.get("test1"));
428-
// Add should fail, even though the get returns null
429-
client.add("test1", 5, "test1value");
430-
assertNull(client.get("test1"));
431-
// Replace should also fail
432-
client.replace("test1", 5, "test1value");
433-
assertNull(client.get("test1"));
434-
// Set should be fine, though.
435-
client.set("test1", 5, "test1value");
436-
assertEquals("test1value", client.get("test1"));
437-
}
438-
439410
public void testFlush() throws Exception {
440411
assertNull(client.get("test1"));
441412
client.set("test1", 5, "test1value");

0 commit comments

Comments
 (0)