This commit is contained in:
Redkale
2020-07-17 12:13:45 +08:00
parent 43486ce1e2
commit 7a80c00439
2 changed files with 14 additions and 0 deletions

View File

@@ -454,6 +454,11 @@ public final class CacheMemorySource<V extends Object> extends AbstractService i
@Override
public <T> Map<String, T> hmap(final String key, final Type type, int offset, int limit) {
return hmap(key, type, offset, limit, null);
}
@Override
public <T> Map<String, T> hmap(final String key, final Type type, int offset, int limit, String pattern) {
if (key == null) return new HashMap();
CacheEntry entry = container.get(key);
if (entry == null || entry.isExpired() || entry.mapValue == null) return new HashMap();
@@ -606,6 +611,11 @@ public final class CacheMemorySource<V extends Object> extends AbstractService i
return CompletableFuture.supplyAsync(() -> hmap(key, type, offset, limit), getExecutor());
}
@Override
public <T> CompletableFuture<Map<String, T>> hmapAsync(final String key, final Type type, int offset, int limit, String pattern) {
return CompletableFuture.supplyAsync(() -> hmap(key, type, offset, limit, pattern), getExecutor());
}
@Override
public <T> CompletableFuture<T> hgetAsync(final String key, final String field, final Type type) {
return CompletableFuture.supplyAsync(() -> hget(key, field, type), getExecutor());

View File

@@ -101,6 +101,8 @@ public interface CacheSource<V extends Object> {
public <T> Map<String, T> hmap(final String key, final Type type, int offset, int limit);
public <T> Map<String, T> hmap(final String key, final Type type, int offset, int limit, String pattern);
public <T> T hget(final String key, final String field, final Type type);
public String hgetString(final String key, final String field);
@@ -336,6 +338,8 @@ public interface CacheSource<V extends Object> {
public <T> CompletableFuture<Map<String, T>> hmapAsync(final String key, final Type type, int offset, int limit);
public <T> CompletableFuture<Map<String, T>> hmapAsync(final String key, final Type type, int offset, int limit, String pattern);
public <T> CompletableFuture<T> hgetAsync(final String key, final String field, final Type type);
public CompletableFuture<String> hgetStringAsync(final String key, final String field);