优化CacheSource

This commit is contained in:
Redkale
2022-12-26 22:59:16 +08:00
parent 441a74a7c9
commit 06bd653b24
2 changed files with 7 additions and 7 deletions

View File

@@ -1614,7 +1614,7 @@ public final class CacheMemorySource extends AbstractCacheSource {
} }
@Override @Override
public int dbsize() { public long dbsize() {
return container.size(); return container.size();
} }
@@ -1649,8 +1649,8 @@ public final class CacheMemorySource extends AbstractCacheSource {
} }
@Override @Override
public CompletableFuture<Integer> dbsizeAsync() { public CompletableFuture<Long> dbsizeAsync() {
return CompletableFuture.completedFuture(container.size()); return CompletableFuture.completedFuture((long) container.size());
} }
@Override @Override

View File

@@ -297,7 +297,7 @@ public interface CacheSource extends Resourcable {
public List<String> keys(String pattern); public List<String> keys(String pattern);
public int dbsize(); public long dbsize();
//------------------------ collection ------------------------ //------------------------ collection ------------------------
@Deprecated @Deprecated
@@ -598,7 +598,7 @@ public interface CacheSource extends Resourcable {
public CompletableFuture<List<String>> keysAsync(String pattern); public CompletableFuture<List<String>> keysAsync(String pattern);
public CompletableFuture<Integer> dbsizeAsync(); public CompletableFuture<Long> dbsizeAsync();
//------------------------ collectionAsync ------------------------ //------------------------ collectionAsync ------------------------
@Deprecated @Deprecated
@@ -1069,11 +1069,11 @@ public interface CacheSource extends Resourcable {
@Deprecated @Deprecated
default CompletableFuture<Integer> getKeySizeAsync() { default CompletableFuture<Integer> getKeySizeAsync() {
return dbsizeAsync(); return dbsizeAsync().thenApply(v -> v.intValue());
} }
@Deprecated @Deprecated
default int getKeySize() { default int getKeySize() {
return dbsize(); return (int) dbsize();
} }
} }