优化CacheSource
This commit is contained in:
@@ -1120,6 +1120,28 @@ public final class CacheMemorySource extends AbstractCacheSource {
|
|||||||
return collection == null ? 0 : collection.size();
|
return collection == null ? 0 : collection.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int llen(final String key) {
|
||||||
|
Collection collection = (Collection) get(key, Object.class);
|
||||||
|
return collection == null ? 0 : collection.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int scard(final String key) {
|
||||||
|
Collection collection = (Collection) get(key, Object.class);
|
||||||
|
return collection == null ? 0 : collection.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Integer> llenAsync(final String key) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> llen(key), getExecutor());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Integer> scardAsync(final String key) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> scard(key), getExecutor());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Integer> getCollectionSizeAsync(final String key) {
|
public CompletableFuture<Integer> getCollectionSizeAsync(final String key) {
|
||||||
return CompletableFuture.supplyAsync(() -> getCollectionSize(key), getExecutor());
|
return CompletableFuture.supplyAsync(() -> getCollectionSize(key), getExecutor());
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ public interface CacheSource extends Resourcable {
|
|||||||
public <T> Map<String, T> hmap(final String key, final Type type, int offset, int limit, String pattern);
|
public <T> Map<String, T> hmap(final String key, final Type type, int offset, int limit, String pattern);
|
||||||
|
|
||||||
//------------------------ list ------------------------
|
//------------------------ list ------------------------
|
||||||
|
public int llen(final String key);
|
||||||
|
|
||||||
public <T> List<T> lrange(final String key, final Type componentType);
|
public <T> List<T> lrange(final String key, final Type componentType);
|
||||||
|
|
||||||
public <T> Map<String, List<T>> lrange(final Type componentType, final String... keys);
|
public <T> Map<String, List<T>> lrange(final Type componentType, final String... keys);
|
||||||
@@ -194,6 +196,8 @@ public interface CacheSource extends Resourcable {
|
|||||||
public int lremLong(final String key, final long value);
|
public int lremLong(final String key, final long value);
|
||||||
|
|
||||||
//------------------------ set ------------------------
|
//------------------------ set ------------------------
|
||||||
|
public int scard(final String key);
|
||||||
|
|
||||||
public <T> Set<T> smembers(final String key, final Type componentType);
|
public <T> Set<T> smembers(final String key, final Type componentType);
|
||||||
|
|
||||||
public <T> Map<String, Set<T>> smembers(final Type componentType, final String... keys);
|
public <T> Map<String, Set<T>> smembers(final Type componentType, final String... keys);
|
||||||
@@ -426,6 +430,8 @@ public interface CacheSource extends Resourcable {
|
|||||||
public <T> CompletableFuture<Map<String, T>> hmapAsync(final String key, final Type type, int offset, int limit, String pattern);
|
public <T> CompletableFuture<Map<String, T>> hmapAsync(final String key, final Type type, int offset, int limit, String pattern);
|
||||||
|
|
||||||
//------------------------ listAsync ------------------------
|
//------------------------ listAsync ------------------------
|
||||||
|
public CompletableFuture<Integer> llenAsync(final String key);
|
||||||
|
|
||||||
public <T> CompletableFuture<List<T>> lrangeAsync(final String key, final Type componentType);
|
public <T> CompletableFuture<List<T>> lrangeAsync(final String key, final Type componentType);
|
||||||
|
|
||||||
public <T> CompletableFuture<Map<String, List<T>>> lrangeAsync(final Type componentType, final String... keys);
|
public <T> CompletableFuture<Map<String, List<T>>> lrangeAsync(final Type componentType, final String... keys);
|
||||||
@@ -445,6 +451,8 @@ public interface CacheSource extends Resourcable {
|
|||||||
public CompletableFuture<Integer> lremLongAsync(final String key, final long value);
|
public CompletableFuture<Integer> lremLongAsync(final String key, final long value);
|
||||||
|
|
||||||
//------------------------ setAsync ------------------------
|
//------------------------ setAsync ------------------------
|
||||||
|
public CompletableFuture<Integer> scardAsync(final String key);
|
||||||
|
|
||||||
public <T> CompletableFuture<Set<T>> smembersAsync(final String key, final Type componentType);
|
public <T> CompletableFuture<Set<T>> smembersAsync(final String key, final Type componentType);
|
||||||
|
|
||||||
public <T> CompletableFuture<Map<String, Set<T>>> smembersAsync(final Type componentType, final String... keys);
|
public <T> CompletableFuture<Map<String, Set<T>>> smembersAsync(final Type componentType, final String... keys);
|
||||||
|
|||||||
Reference in New Issue
Block a user