@@ -1022,7 +1022,7 @@ public Object get(String key) {
1022
1022
* Asynchronously get a bunch of objects from the cache.
1023
1023
*
1024
1024
* @param <T>
1025
- * @param keys the keys to request
1025
+ * @param keyIter Iterator that produces keys.
1026
1026
* @param tcIter an iterator of transcoders to serialize and unserialize
1027
1027
* values; the transcoders are matched with the keys in the same
1028
1028
* order. The minimum of the key collection length and number of
@@ -1032,7 +1032,7 @@ public Object get(String key) {
1032
1032
* @throws IllegalStateException in the rare circumstance where queue is too
1033
1033
* full to accept any more requests
1034
1034
*/
1035
- public <T > BulkFuture <Map <String , T >> asyncGetBulk (Collection <String > keys ,
1035
+ public <T > BulkFuture <Map <String , T >> asyncGetBulk (Iterator <String > keyIter ,
1036
1036
Iterator <Transcoder <T >> tcIter ) {
1037
1037
final Map <String , Future <T >> m = new ConcurrentHashMap <String , Future <T >>();
1038
1038
@@ -1046,7 +1046,7 @@ public <T> BulkFuture<Map<String, T>> asyncGetBulk(Collection<String> keys,
1046
1046
final Map <MemcachedNode , Collection <String >> chunks =
1047
1047
new HashMap <MemcachedNode , Collection <String >>();
1048
1048
final NodeLocator locator = mconn .getLocator ();
1049
- Iterator < String > keyIter = keys . iterator ();
1049
+
1050
1050
while (keyIter .hasNext () && tcIter .hasNext ()) {
1051
1051
String key = keyIter .next ();
1052
1052
tcMap .put (key , tcIter .next ());
@@ -1113,6 +1113,41 @@ public void complete() {
1113
1113
return rv ;
1114
1114
}
1115
1115
1116
+ /**
1117
+ * Asynchronously get a bunch of objects from the cache.
1118
+ *
1119
+ * @param <T>
1120
+ * @param keys the keys to request
1121
+ * @param tcIter an iterator of transcoders to serialize and unserialize
1122
+ * values; the transcoders are matched with the keys in the same
1123
+ * order. The minimum of the key collection length and number of
1124
+ * transcoders is used and no exception is thrown if they do not
1125
+ * match
1126
+ * @return a Future result of that fetch
1127
+ * @throws IllegalStateException in the rare circumstance where queue is too
1128
+ * full to accept any more requests
1129
+ */
1130
+ public <T > BulkFuture <Map <String , T >> asyncGetBulk (Collection <String > keys ,
1131
+ Iterator <Transcoder <T >> tcIter ) {
1132
+ return asyncGetBulk (keys .iterator (), tcIter );
1133
+ }
1134
+
1135
+ /**
1136
+ * Asynchronously get a bunch of objects from the cache.
1137
+ *
1138
+ * @param <T>
1139
+ * @param keyIter Iterator for the keys to request
1140
+ * @param tc the transcoder to serialize and unserialize values
1141
+ * @return a Future result of that fetch
1142
+ * @throws IllegalStateException in the rare circumstance where queue is too
1143
+ * full to accept any more requests
1144
+ */
1145
+ public <T > BulkFuture <Map <String , T >> asyncGetBulk (Iterator <String > keyIter ,
1146
+ Transcoder <T > tc ) {
1147
+ return asyncGetBulk (keyIter ,
1148
+ new SingleElementInfiniteIterator <Transcoder <T >>(tc ));
1149
+ }
1150
+
1116
1151
/**
1117
1152
* Asynchronously get a bunch of objects from the cache.
1118
1153
*
@@ -1129,6 +1164,20 @@ public <T> BulkFuture<Map<String, T>> asyncGetBulk(Collection<String> keys,
1129
1164
tc ));
1130
1165
}
1131
1166
1167
+ /**
1168
+ * Asynchronously get a bunch of objects from the cache and decode them with
1169
+ * the given transcoder.
1170
+ *
1171
+ * @param keyIter Iterator that produces the keys to request
1172
+ * @return a Future result of that fetch
1173
+ * @throws IllegalStateException in the rare circumstance where queue is too
1174
+ * full to accept any more requests
1175
+ */
1176
+ public BulkFuture <Map <String , Object >> asyncGetBulk (
1177
+ Iterator <String > keyIter ) {
1178
+ return asyncGetBulk (keyIter , transcoder );
1179
+ }
1180
+
1132
1181
/**
1133
1182
* Asynchronously get a bunch of objects from the cache and decode them with
1134
1183
* the given transcoder.
@@ -1228,18 +1277,18 @@ public void gotData(String k, int flags, long cas, byte[] data) {
1228
1277
* Get the values for multiple keys from the cache.
1229
1278
*
1230
1279
* @param <T>
1231
- * @param keys the keys
1280
+ * @param keyIter Iterator that produces the keys
1232
1281
* @param tc the transcoder to serialize and unserialize value
1233
1282
* @return a map of the values (for each value that exists)
1234
1283
* @throws OperationTimeoutException if the global operation timeout is
1235
1284
* exceeded
1236
1285
* @throws IllegalStateException in the rare circumstance where queue is too
1237
1286
* full to accept any more requests
1238
1287
*/
1239
- public <T > Map <String , T > getBulk (Collection <String > keys ,
1288
+ public <T > Map <String , T > getBulk (Iterator <String > keyIter ,
1240
1289
Transcoder <T > tc ) {
1241
1290
try {
1242
- return asyncGetBulk (keys , tc ).get (operationTimeout ,
1291
+ return asyncGetBulk (keyIter , tc ).get (operationTimeout ,
1243
1292
TimeUnit .MILLISECONDS );
1244
1293
} catch (InterruptedException e ) {
1245
1294
throw new RuntimeException ("Interrupted getting bulk values" , e );
@@ -1250,6 +1299,37 @@ public <T> Map<String, T> getBulk(Collection<String> keys,
1250
1299
}
1251
1300
}
1252
1301
1302
+ /**
1303
+ * Get the values for multiple keys from the cache.
1304
+ *
1305
+ * @param keyIter Iterator that produces the keys
1306
+ * @return a map of the values (for each value that exists)
1307
+ * @throws OperationTimeoutException if the global operation timeout is
1308
+ * exceeded
1309
+ * @throws IllegalStateException in the rare circumstance where queue is too
1310
+ * full to accept any more requests
1311
+ */
1312
+ public Map <String , Object > getBulk (Iterator <String > keyIter ) {
1313
+ return getBulk (keyIter , transcoder );
1314
+ }
1315
+
1316
+ /**
1317
+ * Get the values for multiple keys from the cache.
1318
+ *
1319
+ * @param <T>
1320
+ * @param keys the keys
1321
+ * @param tc the transcoder to serialize and unserialize value
1322
+ * @return a map of the values (for each value that exists)
1323
+ * @throws OperationTimeoutException if the global operation timeout is
1324
+ * exceeded
1325
+ * @throws IllegalStateException in the rare circumstance where queue is too
1326
+ * full to accept any more requests
1327
+ */
1328
+ public <T > Map <String , T > getBulk (Collection <String > keys ,
1329
+ Transcoder <T > tc ) {
1330
+ return getBulk (keys .iterator (), tc );
1331
+ }
1332
+
1253
1333
/**
1254
1334
* Get the values for multiple keys from the cache.
1255
1335
*
0 commit comments