This commit is contained in:
Redkale
2017-11-09 10:17:31 +08:00
parent 7261bcfadb
commit eabdc13c53
2 changed files with 17 additions and 2 deletions

View File

@@ -75,6 +75,11 @@ public class CacheMemorySource<V extends Object> extends AbstractService impleme
this.needStore = !flag; this.needStore = !flag;
} }
@Override
public boolean isSupportQueryList() {
return true;
}
@Override @Override
public void init(AnyValue conf) { public void init(AnyValue conf) {
if (this.convert == null) this.convert = this.defaultConvert; if (this.convert == null) this.convert = this.defaultConvert;
@@ -155,7 +160,7 @@ public class CacheMemorySource<V extends Object> extends AbstractService impleme
} }
if (remoteSource != null && !Sncp.isRemote(this)) { if (remoteSource != null && !Sncp.isRemote(this)) {
SncpClient client = Sncp.getSncpClient((Service) remoteSource); SncpClient client = Sncp.getSncpClient((Service) remoteSource);
if (client != null && client.getRemoteGroupTransport() != null) { if (client != null && client.getRemoteGroupTransport() != null && remoteSource.isSupportQueryList()) {
super.runAsync(() -> { super.runAsync(() -> {
try { try {
CompletableFuture<List<CacheEntry<Object>>> listFuture = remoteSource.queryListAsync(); CompletableFuture<List<CacheEntry<Object>>> listFuture = remoteSource.queryListAsync();

View File

@@ -30,6 +30,11 @@ public interface CacheSource<V extends Object> {
return true; return true;
} }
//是否支持queryList 或 queryListAsync 方法
default boolean isSupportQueryList() {
return false;
}
public boolean exists(final String key); public boolean exists(final String key);
public V get(final String key); public V get(final String key);
@@ -104,7 +109,12 @@ public interface CacheSource<V extends Object> {
public CompletableFuture<List<CacheEntry< Object>>> queryListAsync(); public CompletableFuture<List<CacheEntry< Object>>> queryListAsync();
default CompletableFuture<Boolean> isOpenAsync() { default CompletableFuture<Boolean> isOpenAsync() {
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(isOpen());
}
//是否支持queryList 或 queryListAsync 方法
default CompletableFuture<Boolean> isSupportQueryListAsync() {
return CompletableFuture.completedFuture(isSupportQueryList());
} }
public static enum CacheEntryType { public static enum CacheEntryType {