diff --git a/src/main/java/net/spy/memcached/ArcusClient.java b/src/main/java/net/spy/memcached/ArcusClient.java index ad8548df5..d6c45da7e 100644 --- a/src/main/java/net/spy/memcached/ArcusClient.java +++ b/src/main/java/net/spy/memcached/ArcusClient.java @@ -1526,6 +1526,11 @@ public CollectionFuture>> asyncBopGet(String key, return asyncBopGet(key, get, reverse, tc); } + @Override + public CollectionFuture> asyncMopGet(String key) { + return asyncMopGet(key, false, false); + } + @Override public CollectionFuture> asyncMopGet(String key, boolean withDelete, @@ -1535,6 +1540,11 @@ public CollectionFuture> asyncMopGet(String key, return asyncMopGet(key, get, collectionTranscoder); } + @Override + public CollectionFuture> asyncMopGet(String key, String mkey) { + return asyncMopGet(key, mkey, false, false); + } + @Override public CollectionFuture> asyncMopGet(String key, String mkey, @@ -1550,6 +1560,11 @@ public CollectionFuture> asyncMopGet(String key, return asyncMopGet(key, get, collectionTranscoder); } + @Override + public CollectionFuture> asyncMopGet(String key, List mkeyList) { + return asyncMopGet(key, mkeyList, false, false); + } + @Override public CollectionFuture> asyncMopGet(String key, List mkeyList, @@ -1565,6 +1580,11 @@ public CollectionFuture> asyncMopGet(String key, return asyncMopGet(key, get, collectionTranscoder); } + @Override + public CollectionFuture> asyncMopGet(String key, Transcoder tc) { + return asyncMopGet(key, false, false, tc); + } + @Override public CollectionFuture> asyncMopGet(String key, boolean withDelete, boolean dropIfEmpty, @@ -1574,6 +1594,11 @@ public CollectionFuture> asyncMopGet(String key, return asyncMopGet(key, get, tc); } + @Override + public CollectionFuture> asyncMopGet(String key, String mkey, Transcoder tc) { + return asyncMopGet(key, mkey, false, false, tc); + } + @Override public CollectionFuture> asyncMopGet(String key, String mkey, @@ -1589,6 +1614,11 @@ public CollectionFuture> asyncMopGet(String key, return asyncMopGet(key, get, tc); } + @Override + public CollectionFuture> asyncMopGet(String key, List mkeyList, Transcoder tc) { + return asyncMopGet(key, mkeyList, false, false, tc); + } + @Override public CollectionFuture> asyncMopGet(String key, List mkeyList, @@ -1604,6 +1634,11 @@ public CollectionFuture> asyncMopGet(String key, return asyncMopGet(key, get, tc); } + @Override + public CollectionFuture> asyncLopGet(String key, int index) { + return asyncLopGet(key, index, false, false); + } + @Override public CollectionFuture> asyncLopGet(String key, int index, boolean withDelete, boolean dropIfEmpty) { @@ -1611,6 +1646,11 @@ public CollectionFuture> asyncLopGet(String key, int index, return asyncLopGet(key, get, collectionTranscoder); } + @Override + public CollectionFuture> asyncLopGet(String key, int from, int to) { + return asyncLopGet(key, from, to, false, false); + } + @Override public CollectionFuture> asyncLopGet(String key, int from, int to, @@ -1619,6 +1659,10 @@ public CollectionFuture> asyncLopGet(String key, return asyncLopGet(key, get, collectionTranscoder); } + @Override + public CollectionFuture> asyncLopGet(String key, int index, Transcoder tc) { + return asyncLopGet(key, index, false, false, tc); + } @Override public CollectionFuture> asyncLopGet(String key, int index, boolean withDelete, boolean dropIfEmpty, @@ -1627,6 +1671,11 @@ public CollectionFuture> asyncLopGet(String key, int index, return asyncLopGet(key, get, tc); } + @Override + public CollectionFuture> asyncLopGet(String key, int from, int to, Transcoder tc) { + return asyncLopGet(key, from, to, false, false, tc); + } + @Override public CollectionFuture> asyncLopGet(String key, int from, int to, @@ -1636,6 +1685,11 @@ public CollectionFuture> asyncLopGet(String key, return asyncLopGet(key, get, tc); } + @Override + public CollectionFuture> asyncSopGet(String key, int count) { + return asyncSopGet(key, count, false, false); + } + @Override public CollectionFuture> asyncSopGet(String key, int count, boolean withDelete, boolean dropIfEmpty) { @@ -1643,6 +1697,11 @@ public CollectionFuture> asyncSopGet(String key, int count, return asyncSopGet(key, get, collectionTranscoder); } + @Override + public CollectionFuture> asyncSopGet(String key, int count, Transcoder tc) { + return asyncSopGet(key, count, false, false, tc); + } + @Override public CollectionFuture> asyncSopGet(String key, int count, boolean withDelete, boolean dropIfEmpty, diff --git a/src/main/java/net/spy/memcached/ArcusClientIF.java b/src/main/java/net/spy/memcached/ArcusClientIF.java index 24ed6f473..a84b7a686 100644 --- a/src/main/java/net/spy/memcached/ArcusClientIF.java +++ b/src/main/java/net/spy/memcached/ArcusClientIF.java @@ -599,6 +599,14 @@ public CollectionFuture>> asyncBopGet(String key, boolean dropIfEmpty, Transcoder tc); + /** + * Retrieves all items from the map + * + * @param key key of a map + * @return a future that will hold the return value map of the fetch + */ + public CollectionFuture> asyncMopGet(String key); + /** * Retrieves all items from the map * @@ -611,6 +619,15 @@ public CollectionFuture>> asyncBopGet(String key, public CollectionFuture> asyncMopGet(String key, boolean withDelete, boolean dropIfEmpty); + /** + * Retrieves an item on given mkey in the map. + * + * @param key key of a map + * @param mkey mkey of a map + * @return a future that will hold the return value map of the fetch + */ + public CollectionFuture> asyncMopGet(String key, String mkey); + /** * Retrieves an item on given mkey in the map. * @@ -624,6 +641,15 @@ public CollectionFuture> asyncMopGet(String key, public CollectionFuture> asyncMopGet(String key, String mkey, boolean withDelete, boolean dropIfEmpty); + /** + * Retrieves items on given mkey list in the map. + * + * @param key key of a map + * @param mkeyList mkeyList + * @return a future that will hold the return value map of the fetch. + */ + public CollectionFuture> asyncMopGet(String key, List mkeyList); + /** * Retrieves items on given mkey list in the map. * @@ -637,6 +663,17 @@ public CollectionFuture> asyncMopGet(String key, String mkey public CollectionFuture> asyncMopGet(String key, List mkeyList, boolean withDelete, boolean dropIfEmpty); + /** + * Retrieves all items from the map + * + * @param the expected class of the value + * @param key key of a map + * @param tc a transcoder to decode returned values + * @return a future that will hold the return value map of the fetch + */ + public CollectionFuture> asyncMopGet(String key, + Transcoder tc); + /** * Retrieves all items from the map * @@ -652,6 +689,18 @@ public CollectionFuture> asyncMopGet(String key, boolean withDelete, boolean dropIfEmpty, Transcoder tc); + /** + * Retrieves an item on given mkey in the map. + * + * @param the expected class of the value + * @param key key of a map + * @param mkey mkey of a map + * @param tc a transcoder to decode returned values + * @return a future that will hold the return value map of the fetch + */ + public CollectionFuture> asyncMopGet(String key, String mkey, + Transcoder tc); + /** * Retrieves an item on given mkey in the map. * @@ -668,6 +717,18 @@ public CollectionFuture> asyncMopGet(String key, String mkey, boolean withDelete, boolean dropIfEmpty, Transcoder tc); + /** + * Retrieves items on given mkey list in the map. + * + * @param the expected class of the value + * @param key key of a map + * @param mkeyList mkeyList + * @param tc a transcoder to decode returned values + * @return a future that will hold the return value map of the fetch. + */ + public CollectionFuture> asyncMopGet(String key, List mkeyList, + Transcoder tc); + /** * Retrieves items on given mkey list in the map. * @@ -684,6 +745,15 @@ public CollectionFuture> asyncMopGet(String key, List boolean withDelete, boolean dropIfEmpty, Transcoder tc); + /** + * Retrieves an item on given index in the list. + * + * @param key key of a list + * @param index list index + * @return a future that will hold the return value list of the fetch + */ + public CollectionFuture> asyncLopGet(String key, int index); + /** * Retrieves an item on given index in the list. * @@ -697,6 +767,17 @@ public CollectionFuture> asyncMopGet(String key, List public CollectionFuture> asyncLopGet(String key, int index, boolean withDelete, boolean dropIfEmpty); + /** + * Retrieves items on given index range(from..to) in the list. + * + * @param key key of a list + * @param from the first index to delete + * @param to the last index to delete + * @return a future that will hold the return value list of the fetch + */ + public CollectionFuture> asyncLopGet(String key, + int from, int to); + /** * Retrieves items on given index range(from..to) in the list. * @@ -712,6 +793,18 @@ public CollectionFuture> asyncLopGet(String key, int from, int to, boolean withDelete, boolean dropIfEmpty); + /** + * Retrieves an item on given index in the list. + * + * @param the expected class of the value + * @param key key of a list + * @param index list index + * @param tc a tranacoder to decode returned value + * @return a future that will hold the return value list of the fetch + */ + public CollectionFuture> asyncLopGet(String key, int index, + Transcoder tc); + /** * Retrieves an item on given index in the list. * @@ -728,6 +821,20 @@ public CollectionFuture> asyncLopGet(String key, int index, boolean withDelete, boolean dropIfEmpty, Transcoder tc); + /** + * Retrieves items on given index range(from..to) in the list. (Arcus 1.6 and above) + * + * @param the expected class of the value + * @param key key of a list + * @param from the first index to delete + * @param to the last index to delete + * @param tc a transcoder to decode the returned values + * @return a future that will hold the return value list of the fetch + */ + public CollectionFuture> asyncLopGet(String key, + int from, int to, + Transcoder tc); + /** * Retrieves items on given index range(from..to) in the list. (Arcus 1.6 and above) * @@ -746,6 +853,15 @@ public CollectionFuture> asyncLopGet(String key, boolean withDelete, boolean dropIfEmpty, Transcoder tc); + /** + * Retrieves count number of random items in the set. + * + * @param key key of a set + * @param count number of items to fetch + * @return a future that will hold the return value set of the fetch + */ + public CollectionFuture> asyncSopGet(String key, int count); + /** * Retrieves count number of random items in the set. * @@ -759,6 +875,18 @@ public CollectionFuture> asyncLopGet(String key, public CollectionFuture> asyncSopGet(String key, int count, boolean withDelete, boolean dropIfEmpty); + /** + * Retrieves count number of random items in the set. + * + * @param the expected class of the value + * @param key key of a set + * @param count number of items to fetch + * @param tc a tranacoder to decode returned value + * @return a future that will hold the return value set of the fetch + */ + public CollectionFuture> asyncSopGet(String key, int count, + Transcoder tc); + /** * Retrieves count number of random items in the set. * diff --git a/src/main/java/net/spy/memcached/ArcusClientPool.java b/src/main/java/net/spy/memcached/ArcusClientPool.java index be95be758..243d8e179 100644 --- a/src/main/java/net/spy/memcached/ArcusClientPool.java +++ b/src/main/java/net/spy/memcached/ArcusClientPool.java @@ -700,10 +700,8 @@ public CollectionFuture>> asyncBopGet(String key, } @Override - public CollectionFuture> asyncMopGet(String key, List mkeyList, - boolean withDelete, - boolean dropIfEmpty) { - return this.getClient().asyncMopGet(key, mkeyList, withDelete, dropIfEmpty); + public CollectionFuture> asyncMopGet(String key) { + return this.getClient().asyncMopGet(key); } @Override @@ -713,6 +711,11 @@ public CollectionFuture> asyncMopGet(String key, return this.getClient().asyncMopGet(key, withDelete, dropIfEmpty); } + @Override + public CollectionFuture> asyncMopGet(String key, String mkey) { + return this.getClient().asyncMopGet(key, mkey); + } + @Override public CollectionFuture> asyncMopGet(String key, String mkey, boolean withDelete, @@ -721,11 +724,20 @@ public CollectionFuture> asyncMopGet(String key, String mkey } @Override - public CollectionFuture> asyncMopGet(String key, List mkeyList, - boolean withDelete, - boolean dropIfEmpty, - Transcoder tc) { - return this.getClient().asyncMopGet(key, mkeyList, withDelete, dropIfEmpty, tc); + public CollectionFuture> asyncMopGet(String key, List mkeyList) { + return this.getClient().asyncMopGet(key, mkeyList); + } + + @Override + public CollectionFuture> asyncMopGet(String key, List mkeyList, + boolean withDelete, + boolean dropIfEmpty) { + return this.getClient().asyncMopGet(key, mkeyList, withDelete, dropIfEmpty); + } + + @Override + public CollectionFuture> asyncMopGet(String key, Transcoder tc) { + return this.getClient().asyncMopGet(key, tc); } @Override @@ -736,6 +748,12 @@ public CollectionFuture> asyncMopGet(String key, return this.getClient().asyncMopGet(key, withDelete, dropIfEmpty, tc); } + @Override + public CollectionFuture> asyncMopGet(String key, String mkey, + Transcoder tc) { + return this.getClient().asyncMopGet(key, mkey, tc); + } + @Override public CollectionFuture> asyncMopGet(String key, String mkey, boolean withDelete, @@ -744,6 +762,26 @@ public CollectionFuture> asyncMopGet(String key, String mkey, return this.getClient().asyncMopGet(key, mkey, withDelete, dropIfEmpty, tc); } + @Override + public CollectionFuture> asyncMopGet(String key, List mkeyList, + Transcoder tc) { + return this.getClient().asyncMopGet(key, mkeyList, tc); + } + + @Override + public CollectionFuture> asyncMopGet(String key, List mkeyList, + boolean withDelete, + boolean dropIfEmpty, + Transcoder tc) { + return this.getClient().asyncMopGet(key, mkeyList, withDelete, dropIfEmpty, tc); + } + + @Override + public CollectionFuture> asyncLopGet(String key, int index) { + return this.getClient() + .asyncLopGet(key, index); + } + @Override public CollectionFuture> asyncLopGet(String key, int index, boolean withDelete, @@ -752,6 +790,11 @@ public CollectionFuture> asyncLopGet(String key, int index, .asyncLopGet(key, index, withDelete, dropIfEmpty); } + @Override + public CollectionFuture> asyncLopGet(String key, int from, int to) { + return this.getClient().asyncLopGet(key, from, to); + } + @Override public CollectionFuture> asyncLopGet(String key, int from, int to, @@ -761,6 +804,11 @@ public CollectionFuture> asyncLopGet(String key, dropIfEmpty); } + @Override + public CollectionFuture> asyncLopGet(String key, int index, Transcoder tc) { + return this.getClient().asyncLopGet(key, index, tc); + } + @Override public CollectionFuture> asyncLopGet(String key, int index, boolean withDelete, @@ -770,6 +818,11 @@ public CollectionFuture> asyncLopGet(String key, int index, dropIfEmpty, tc); } + @Override + public CollectionFuture> asyncLopGet(String key, int from, int to, Transcoder tc) { + return this.getClient().asyncLopGet(key, from, to, tc); + } + @Override public CollectionFuture> asyncLopGet(String key, int from, int to, @@ -780,6 +833,12 @@ public CollectionFuture> asyncLopGet(String key, dropIfEmpty, tc); } + @Override + public CollectionFuture> asyncSopGet(String key, int count) { + return this.getClient() + .asyncSopGet(key, count); + } + @Override public CollectionFuture> asyncSopGet(String key, int count, @@ -789,6 +848,11 @@ public CollectionFuture> asyncSopGet(String key, .asyncSopGet(key, count, withDelete, dropIfEmpty); } + @Override + public CollectionFuture> asyncSopGet(String key, int count, Transcoder tc) { + return this.getClient().asyncSopGet(key, count, tc); + } + @Override public CollectionFuture> asyncSopGet(String key, int count, diff --git a/src/test/manual/net/spy/memcached/collection/list/LopGetTest.java b/src/test/manual/net/spy/memcached/collection/list/LopGetTest.java index 59567b655..1dae9163e 100644 --- a/src/test/manual/net/spy/memcached/collection/list/LopGetTest.java +++ b/src/test/manual/net/spy/memcached/collection/list/LopGetTest.java @@ -100,4 +100,17 @@ public void testLopGet_GetWithDeletion() throws Exception { assertNull(rlist); } + public void testLopGet_simple() throws Exception { + CollectionAttributes attrs = null; + + // get all elements + List list = mc.asyncLopGet(key, 0, 9).get(1000, + TimeUnit.MILLISECONDS); + + assertEquals(list.size(), 9); + + // get count of the list and compare with count of items after using get method + attrs = mc.asyncGetAttr(key).get(1000, TimeUnit.MILLISECONDS); + assertEquals(9, attrs.getCount().intValue()); + } } diff --git a/src/test/manual/net/spy/memcached/collection/map/MopGetTest.java b/src/test/manual/net/spy/memcached/collection/map/MopGetTest.java index ca633a73d..a1afd5583 100644 --- a/src/test/manual/net/spy/memcached/collection/map/MopGetTest.java +++ b/src/test/manual/net/spy/memcached/collection/map/MopGetTest.java @@ -114,4 +114,23 @@ public void testMopGet_GetWithDeletion() throws Exception { TimeUnit.MILLISECONDS); assertNull(rmap); } + + public void testMopGet_simple() throws Exception { + CollectionAttributes attrs = null; + + List mKeyList = new ArrayList(); + for (int i = 0; i <= 9; i++) { + mKeyList.add(String.valueOf(i)); + } + + // get all elements + Map list = mc.asyncMopGet(key, mKeyList).get(1000, + TimeUnit.MILLISECONDS); + + assertEquals(list.size(), 9); + + // get count of the map and compare with count of items after using get method + attrs = mc.asyncGetAttr(key).get(1000, TimeUnit.MILLISECONDS); + assertEquals(9, attrs.getCount().intValue()); + } } diff --git a/src/test/manual/net/spy/memcached/emptycollection/GetWithDropSetTest.java b/src/test/manual/net/spy/memcached/emptycollection/GetWithDropSetTest.java index defa588ef..a53a6367f 100644 --- a/src/test/manual/net/spy/memcached/emptycollection/GetWithDropSetTest.java +++ b/src/test/manual/net/spy/memcached/emptycollection/GetWithDropSetTest.java @@ -105,4 +105,27 @@ public void testGetWithtDeleteAndWithDrop() { Assert.fail(e.getMessage()); } } + + public void testGetWithoutDeleteAndDropOptions() { + try { + // check attr + assertEquals(new Long(1), mc.asyncGetAttr(KEY).get() + .getCount()); + + //get value + assertTrue(mc.asyncSopGet(KEY, 10).get() + .contains(VALUE)); + + // check exists + assertEquals(new Long(1), mc.asyncGetAttr(KEY).get() + .getCount()); + + // get value again + assertTrue(mc.asyncSopGet(KEY, 10).get() + .contains(VALUE)); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } }