@@ -980,6 +980,106 @@ public GetFuture<CASValue<Object>> asyncGets(final String key) {
980980 return asyncGets (key , transcoder );
981981 }
982982
983+ /**
984+ * Get the given key to reset its expiration time asynchronously.
985+ *
986+ * @param key the key to fetch
987+ * @param exp the new expiration to set for the given key
988+ * @param tc the transcoder to serialize and unserialize value
989+ * @return a future that will hold the return value of the fetch
990+ * @throws IllegalStateException in the rare circumstance where queue is too
991+ * full to accept any more requests
992+ */
993+ public <T > GetFuture <T > asyncGetAndTouch (final String key , final int exp ,
994+ final Transcoder <T > tc ) {
995+ final CountDownLatch latch = new CountDownLatch (1 );
996+ final GetFuture <T > future = new GetFuture <>(latch , operationTimeout );
997+
998+ Operation op = opFact .getAndTouch (key , exp ,
999+ new GetOperation .Callback () {
1000+ private GetResult <T > result = null ;
1001+
1002+ public void receivedStatus (OperationStatus status ) {
1003+ future .set (result , status );
1004+ }
1005+
1006+ public void gotData (String k , int flags , byte [] data ) {
1007+ assert k .equals (key ) : "Wrong key returned" ;
1008+ result = new GetResultImpl <>(new CachedData (flags , data , tc .getMaxSize ()), tc );
1009+ }
1010+
1011+ public void complete () {
1012+ latch .countDown ();
1013+ }
1014+ });
1015+ future .setOperation (op );
1016+ addOp (key , op );
1017+ return future ;
1018+ }
1019+
1020+ /**
1021+ * Get the given key to reset its expiration time asynchronously.
1022+ *
1023+ * @param key the key to fetch
1024+ * @param exp the new expiration to set for the given key
1025+ * @return a future that will hold the return value of the fetch
1026+ * @throws IllegalStateException in the rare circumstance where queue is too
1027+ * full to accept any more requests
1028+ */
1029+ public GetFuture <Object > asyncGetAndTouch (final String key , final int exp ) {
1030+ return asyncGetAndTouch (key , exp , transcoder );
1031+ }
1032+
1033+ /**
1034+ * Gets (with CAS support) the given key to reset its expiration time asynchronously.
1035+ *
1036+ * @param key the key to fetch
1037+ * @param exp the new expiration to set for the given key
1038+ * @param tc the transcoder to serialize and unserialize value
1039+ * @return a future that will hold the return value of the fetch
1040+ * @throws IllegalStateException in the rare circumstance where queue is too
1041+ * full to accept any more requests
1042+ */
1043+ public <T > GetFuture <CASValue <T >> asyncGetsAndTouch (final String key , final int exp ,
1044+ final Transcoder <T > tc ) {
1045+ final CountDownLatch latch = new CountDownLatch (1 );
1046+ final GetFuture <CASValue <T >> rv = new GetFuture <>(latch , operationTimeout );
1047+
1048+ Operation op = opFact .getsAndTouch (key , exp , new GetsOperation .Callback () {
1049+ private GetResult <CASValue <T >> val = null ;
1050+
1051+ public void receivedStatus (OperationStatus status ) {
1052+ rv .set (val , status );
1053+ }
1054+
1055+ public void gotData (String k , int flags , long cas , byte [] data ) {
1056+ assert key .equals (k ) : "Wrong key returned" ;
1057+ assert cas > 0 : "CAS was less than zero: " + cas ;
1058+ val = new GetsResultImpl <>(cas , new CachedData (flags , data , tc .getMaxSize ()), tc );
1059+ }
1060+
1061+ public void complete () {
1062+ latch .countDown ();
1063+ }
1064+ });
1065+ rv .setOperation (op );
1066+ addOp (key , op );
1067+ return rv ;
1068+ }
1069+
1070+ /**
1071+ * Gets (with CAS support) the given key to reset its expiration time asynchronously.
1072+ *
1073+ * @param key the key to fetch
1074+ * @param exp the new expiration to set for the given key
1075+ * @return a future that will hold the return value of the fetch
1076+ * @throws IllegalStateException in the rare circumstance where queue is too
1077+ * full to accept any more requests
1078+ */
1079+ public GetFuture <CASValue <Object >> asyncGetsAndTouch (final String key , final int exp ) {
1080+ return asyncGetsAndTouch (key , exp , transcoder );
1081+ }
1082+
9831083 /**
9841084 * Gets (with CAS support) with a single key.
9851085 *
0 commit comments