This commit is contained in:
Redkale
2020-08-11 19:57:17 +08:00
parent e3a8c2d392
commit 5c810b5ff6
2 changed files with 16 additions and 0 deletions

View File

@@ -355,6 +355,13 @@ public final class CacheMemorySource<V extends Object> extends AbstractService i
return list;
}
@Override
public int hsize(final String key) {
CacheEntry entry = container.get(key);
if (entry == null || entry.mapValue == null) return 0;
return entry.mapValue.keySet().size();
}
@Override
public long hincr(final String key, String field) {
return hincr(key, field, 1);
@@ -551,6 +558,11 @@ public final class CacheMemorySource<V extends Object> extends AbstractService i
return CompletableFuture.supplyAsync(() -> hkeys(key), getExecutor());
}
@Override
public CompletableFuture<Integer> hsizeAsync(final String key) {
return CompletableFuture.supplyAsync(() -> hsize(key), getExecutor());
}
@Override
public CompletableFuture<Long> hincrAsync(final String key, String field) {
return CompletableFuture.supplyAsync(() -> hincr(key, field), getExecutor());

View File

@@ -75,6 +75,8 @@ public interface CacheSource<V extends Object> {
public List<String> hkeys(final String key);
public int hsize(final String key);
public long hincr(final String key, String field);
public long hincr(final String key, String field, long num);
@@ -324,6 +326,8 @@ public interface CacheSource<V extends Object> {
public CompletableFuture<List<String>> hkeysAsync(final String key);
public CompletableFuture<Integer> hsizeAsync(final String key);
public CompletableFuture<Long> hincrAsync(final String key, String field);
public CompletableFuture<Long> hincrAsync(final String key, String field, long num);