CacheSource 增加get多个keys值得系列方法
This commit is contained in:
@@ -673,37 +673,31 @@ public class CacheMemorySource<V extends Object> extends AbstractService impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public CompletableFuture<Long> incrAsync(final String key, long num) {
|
||||
return CompletableFuture.supplyAsync(() -> incr(key, num), getExecutor()).whenComplete(futureCompleteConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public long decr(final String key) {
|
||||
return incr(key, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public CompletableFuture<Long> decrAsync(final String key) {
|
||||
return CompletableFuture.supplyAsync(() -> decr(key), getExecutor()).whenComplete(futureCompleteConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public long decr(final String key, long num) {
|
||||
return incr(key, -num);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public CompletableFuture<Long> decrAsync(final String key, long num) {
|
||||
return CompletableFuture.supplyAsync(() -> decr(key, num), getExecutor()).whenComplete(futureCompleteConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public CompletableFuture<Void> removeAsync(final String key) {
|
||||
return CompletableFuture.runAsync(() -> remove(key), getExecutor()).whenComplete(futureCompleteConsumer);
|
||||
}
|
||||
@@ -743,6 +737,50 @@ public class CacheMemorySource<V extends Object> extends AbstractService impleme
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Long> getLongMap(final String... keys) {
|
||||
Map<String, Long> map = new LinkedHashMap<>();
|
||||
for (String key : keys) {
|
||||
Number n = (Number) get(key);
|
||||
map.put(key, n == null ? null : n.longValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Map<String, Long>> getLongMapAsync(final String... keys) {
|
||||
return CompletableFuture.supplyAsync(() -> getLongMap(keys), getExecutor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getStringMap(final String... keys) {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
for (String key : keys) {
|
||||
Object n = get(key);
|
||||
map.put(key, n == null ? null : n.toString());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Map<String, String>> getStringMapAsync(final String... keys) {
|
||||
return CompletableFuture.supplyAsync(() -> getStringMap(keys), getExecutor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Map<String, T> getMap(final Type componentType, final String... keys) {
|
||||
Map<String, T> map = new LinkedHashMap<>();
|
||||
for (String key : keys) {
|
||||
map.put(key, (T) get(key));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CompletableFuture<Map<String, T>> getMapAsync(final Type componentType, final String... keys) {
|
||||
return CompletableFuture.supplyAsync(() -> getMap(componentType, keys), getExecutor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Long> getLongCollection(final String key) {
|
||||
return (Collection<Long>) get(key);
|
||||
|
||||
@@ -99,6 +99,8 @@ public interface CacheSource<V extends Object> {
|
||||
|
||||
public long decr(final String key, long num);
|
||||
|
||||
public <T> Map<String, T> getMap(final Type componentType, final String... keys);
|
||||
|
||||
public Collection<V> getCollection(final String key);
|
||||
|
||||
public <T> Collection<T> getCollection(final String key, final Type componentType);
|
||||
@@ -149,6 +151,8 @@ public interface CacheSource<V extends Object> {
|
||||
|
||||
public void setString(final int expireSeconds, final String key, final String value);
|
||||
|
||||
public Map<String, String> getStringMap(final String... keys);
|
||||
|
||||
public Collection<String> getStringCollection(final String key);
|
||||
|
||||
public Map<String, Collection<String>> getStringCollectionMap(final boolean set, final String... keys);
|
||||
@@ -173,6 +177,8 @@ public interface CacheSource<V extends Object> {
|
||||
|
||||
public void setLong(final int expireSeconds, final String key, final long value);
|
||||
|
||||
public Map<String, Long> getLongMap(final String... keys);
|
||||
|
||||
public Collection<Long> getLongCollection(final String key);
|
||||
|
||||
public Map<String, Collection<Long>> getLongCollectionMap(final boolean set, final String... keys);
|
||||
@@ -256,6 +262,8 @@ public interface CacheSource<V extends Object> {
|
||||
|
||||
public CompletableFuture<Long> decrAsync(final String key, long num);
|
||||
|
||||
public <T> CompletableFuture<Map<String, T>> getMapAsync(final Type componentType, final String... keys);
|
||||
|
||||
public CompletableFuture<Collection<V>> getCollectionAsync(final String key);
|
||||
|
||||
public <T> CompletableFuture<Collection<T>> getCollectionAsync(final String key, final Type componentType);
|
||||
@@ -306,6 +314,8 @@ public interface CacheSource<V extends Object> {
|
||||
|
||||
public CompletableFuture<Void> setStringAsync(final int expireSeconds, final String key, final String value);
|
||||
|
||||
public CompletableFuture<Map<String, String>> getStringMapAsync(final String... keys);
|
||||
|
||||
public CompletableFuture<Collection<String>> getStringCollectionAsync(final String key);
|
||||
|
||||
public CompletableFuture<Map<String, Collection<String>>> getStringCollectionMapAsync(final boolean set, final String... keys);
|
||||
@@ -330,6 +340,8 @@ public interface CacheSource<V extends Object> {
|
||||
|
||||
public CompletableFuture<Void> setLongAsync(final int expireSeconds, final String key, final long value);
|
||||
|
||||
public CompletableFuture<Map<String, Long>> getLongMapAsync(final String... keys);
|
||||
|
||||
public CompletableFuture<Collection<Long>> getLongCollectionAsync(final String key);
|
||||
|
||||
public CompletableFuture<Map<String, Collection<Long>>> getLongCollectionMapAsync(final boolean set, final String... keys);
|
||||
|
||||
Reference in New Issue
Block a user