CacheSource增加getKeySize方法
This commit is contained in:
@@ -348,13 +348,13 @@ public class CacheMemorySource<K extends Serializable, V extends Object> extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCollectionSize(final K key) {
|
public int getCollectionSize(final K key) {
|
||||||
Collection<V> collection = (Collection<V>) get(key);
|
Collection<V> collection = (Collection<V>) get(key);
|
||||||
return collection == null ? 0 : collection.size();
|
return collection == null ? 0 : collection.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Long> getCollectionSizeAsync(final K key) {
|
public CompletableFuture<Integer> getCollectionSizeAsync(final K key) {
|
||||||
return CompletableFuture.supplyAsync(() -> getCollectionSize(key), getExecutor());
|
return CompletableFuture.supplyAsync(() -> getCollectionSize(key), getExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,6 +443,11 @@ public class CacheMemorySource<K extends Serializable, V extends Object> extends
|
|||||||
return new ArrayList<>(container.keySet());
|
return new ArrayList<>(container.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getKeySize() {
|
||||||
|
return container.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<List<CacheEntry<K, Object>>> queryListAsync() {
|
public CompletableFuture<List<CacheEntry<K, Object>>> queryListAsync() {
|
||||||
return CompletableFuture.completedFuture(new ArrayList<>(container.values()));
|
return CompletableFuture.completedFuture(new ArrayList<>(container.values()));
|
||||||
@@ -458,4 +463,8 @@ public class CacheMemorySource<K extends Serializable, V extends Object> extends
|
|||||||
return CompletableFuture.completedFuture(new ArrayList<>(container.keySet()));
|
return CompletableFuture.completedFuture(new ArrayList<>(container.keySet()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Integer> getKeySizeAsync() {
|
||||||
|
return CompletableFuture.completedFuture(container.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public interface CacheSource<K extends Serializable, V extends Object> {
|
|||||||
|
|
||||||
public Collection<V> getCollection(final K key);
|
public Collection<V> getCollection(final K key);
|
||||||
|
|
||||||
public long getCollectionSize(final K key);
|
public int getCollectionSize(final K key);
|
||||||
|
|
||||||
public Collection<V> getCollectionAndRefresh(final K key, final int expireSeconds);
|
public Collection<V> getCollectionAndRefresh(final K key, final int expireSeconds);
|
||||||
|
|
||||||
@@ -59,6 +59,8 @@ public interface CacheSource<K extends Serializable, V extends Object> {
|
|||||||
|
|
||||||
public List<K> queryKeys();
|
public List<K> queryKeys();
|
||||||
|
|
||||||
|
public int getKeySize();
|
||||||
|
|
||||||
public List<CacheEntry<K, Object>> queryList();
|
public List<CacheEntry<K, Object>> queryList();
|
||||||
|
|
||||||
//---------------------- CompletableFuture 异步版 ---------------------------------
|
//---------------------- CompletableFuture 异步版 ---------------------------------
|
||||||
@@ -80,7 +82,7 @@ public interface CacheSource<K extends Serializable, V extends Object> {
|
|||||||
|
|
||||||
public CompletableFuture<Collection<V>> getCollectionAsync(final K key);
|
public CompletableFuture<Collection<V>> getCollectionAsync(final K key);
|
||||||
|
|
||||||
public CompletableFuture<Long> getCollectionSizeAsync(final K key);
|
public CompletableFuture<Integer> getCollectionSizeAsync(final K key);
|
||||||
|
|
||||||
public CompletableFuture<Collection<V>> getCollectionAndRefreshAsync(final K key, final int expireSeconds);
|
public CompletableFuture<Collection<V>> getCollectionAndRefreshAsync(final K key, final int expireSeconds);
|
||||||
|
|
||||||
@@ -94,6 +96,8 @@ public interface CacheSource<K extends Serializable, V extends Object> {
|
|||||||
|
|
||||||
public CompletableFuture<List<K>> queryKeysAsync();
|
public CompletableFuture<List<K>> queryKeysAsync();
|
||||||
|
|
||||||
|
public CompletableFuture<Integer> getKeySizeAsync();
|
||||||
|
|
||||||
public CompletableFuture<List<CacheEntry<K, Object>>> queryListAsync();
|
public CompletableFuture<List<CacheEntry<K, Object>>> queryListAsync();
|
||||||
|
|
||||||
default CompletableFuture<Boolean> isOpenAsync() {
|
default CompletableFuture<Boolean> isOpenAsync() {
|
||||||
|
|||||||
Reference in New Issue
Block a user