Cached优化
This commit is contained in:
@@ -29,7 +29,7 @@ public @interface Cached {
|
||||
* 缓存的key,支持参数动态组合,比如"key_#{id}" <br>
|
||||
* <b>'@'开头的key值视为CacheKeyGenerator对象名称</b> <br>
|
||||
*
|
||||
* @see org.redkale.cache.spi.CacheKeyGenerator#name()
|
||||
* @see org.redkale.cached.spi.CachedKeyGenerator#name()
|
||||
*
|
||||
* @return 键
|
||||
*/
|
||||
@@ -38,9 +38,9 @@ public @interface Cached {
|
||||
/**
|
||||
* 缓存的hash, 不能含有':'、'#'、'@'字符
|
||||
*
|
||||
* @return hash
|
||||
* @return schema
|
||||
*/
|
||||
String hash() default CachedManager.DEFAULT_HASH;
|
||||
String schema() default CachedManager.DEFAULT_SCHEMA;
|
||||
|
||||
/**
|
||||
* 本地缓存过期时长, 0表示永不过期, -1表示不作本地缓存。<br>
|
||||
|
||||
@@ -19,19 +19,19 @@ import org.redkale.util.ThrowSupplier;
|
||||
public interface CachedManager {
|
||||
|
||||
/** 默认的hash */
|
||||
public static final String DEFAULT_HASH = "cached-hash";
|
||||
public static final String DEFAULT_SCHEMA = "cached-schema";
|
||||
|
||||
// -------------------------------------- 本地缓存 --------------------------------------
|
||||
/**
|
||||
* 本地获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> T localGet(final String hash, final String key, final Type type);
|
||||
public <T> T localGet(final String schema, final String key, final Type type);
|
||||
|
||||
/**
|
||||
* 本地获取缓存数据, 过期返回null
|
||||
@@ -42,18 +42,18 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default <T> T localGet(final String key, final Type type) {
|
||||
return localGet(DEFAULT_HASH, key, type);
|
||||
return localGet(DEFAULT_SCHEMA, key, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地获取字符串缓存数据, 过期返回null
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 数据值
|
||||
*/
|
||||
default String localGetString(final String hash, final String key) {
|
||||
return localGet(hash, key, String.class);
|
||||
default String localGetString(final String schema, final String key) {
|
||||
return localGet(schema, key, String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,14 +63,14 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default String localGetString(final String key) {
|
||||
return localGetString(DEFAULT_HASH, key);
|
||||
return localGetString(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -79,7 +79,7 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> T localGetSet(
|
||||
final String hash,
|
||||
final String schema,
|
||||
final String key,
|
||||
final Type type,
|
||||
boolean nullable,
|
||||
@@ -99,14 +99,14 @@ public interface CachedManager {
|
||||
*/
|
||||
default <T> T localGetSet(
|
||||
final String key, final Type type, boolean nullable, Duration expire, ThrowSupplier<T> supplier) {
|
||||
return localGetSet(DEFAULT_HASH, key, type, nullable, expire, supplier);
|
||||
return localGetSet(DEFAULT_SCHEMA, key, type, nullable, expire, supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -115,7 +115,7 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> CompletableFuture<T> localGetSetAsync(
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -135,20 +135,20 @@ public interface CachedManager {
|
||||
*/
|
||||
default <T> CompletableFuture<T> localGetSetAsync(
|
||||
String key, Type type, boolean nullable, Duration expire, ThrowSupplier<CompletableFuture<T>> supplier) {
|
||||
return localGetSetAsync(DEFAULT_HASH, key, type, nullable, expire, supplier);
|
||||
return localGetSetAsync(DEFAULT_SCHEMA, key, type, nullable, expire, supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
public <T> void localSet(String hash, String key, Type type, T value, Duration expire);
|
||||
public <T> void localSet(String schema, String key, Type type, T value, Duration expire);
|
||||
|
||||
/**
|
||||
* 本地缓存数据
|
||||
@@ -160,19 +160,19 @@ public interface CachedManager {
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
default <T> void localSet(String key, Type type, T value, Duration expire) {
|
||||
localSet(DEFAULT_HASH, key, type, value, expire);
|
||||
localSet(DEFAULT_SCHEMA, key, type, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地缓存字符串数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
default void localSetString(final String hash, final String key, final String value, Duration expire) {
|
||||
localSet(hash, key, String.class, value, expire);
|
||||
default void localSetString(final String schema, final String key, final String value, Duration expire) {
|
||||
localSet(schema, key, String.class, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,17 +183,17 @@ public interface CachedManager {
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
default void localSetString(final String key, final String value, Duration expire) {
|
||||
localSetString(DEFAULT_HASH, key, value, expire);
|
||||
localSetString(DEFAULT_SCHEMA, key, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
public long localDel(String hash, String key);
|
||||
public long localDel(String schema, String key);
|
||||
|
||||
/**
|
||||
* 本地删除缓存数据
|
||||
@@ -202,7 +202,7 @@ public interface CachedManager {
|
||||
* @return 删除数量
|
||||
*/
|
||||
default long localDel(String key) {
|
||||
return localDel(DEFAULT_HASH, key);
|
||||
return localDel(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
// -------------------------------------- 远程缓存 --------------------------------------
|
||||
@@ -210,12 +210,12 @@ public interface CachedManager {
|
||||
* 远程获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> T remoteGet(final String hash, final String key, final Type type);
|
||||
public <T> T remoteGet(final String schema, final String key, final Type type);
|
||||
|
||||
/**
|
||||
* 远程获取缓存数据, 过期返回null
|
||||
@@ -226,18 +226,18 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default <T> T remoteGet(final String key, final Type type) {
|
||||
return remoteGet(DEFAULT_HASH, key, type);
|
||||
return remoteGet(DEFAULT_SCHEMA, key, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取字符串缓存数据, 过期返回null
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 数据值
|
||||
*/
|
||||
default String remoteGetString(final String hash, final String key) {
|
||||
return remoteGet(hash, key, String.class);
|
||||
default String remoteGetString(final String schema, final String key) {
|
||||
return remoteGet(schema, key, String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,19 +247,19 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default String remoteGetString(final String key) {
|
||||
return remoteGetString(DEFAULT_HASH, key);
|
||||
return remoteGetString(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> CompletableFuture<T> remoteGetAsync(final String hash, final String key, final Type type);
|
||||
public <T> CompletableFuture<T> remoteGetAsync(final String schema, final String key, final Type type);
|
||||
|
||||
/**
|
||||
* 远程异步获取缓存数据, 过期返回null
|
||||
@@ -270,18 +270,18 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default <T> CompletableFuture<T> remoteGetAsync(final String key, final Type type) {
|
||||
return remoteGetAsync(DEFAULT_HASH, key, type);
|
||||
return remoteGetAsync(DEFAULT_SCHEMA, key, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步获取字符串缓存数据, 过期返回null
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 数据值
|
||||
*/
|
||||
default CompletableFuture<String> remoteGetStringAsync(final String hash, final String key) {
|
||||
return remoteGetAsync(hash, key, String.class);
|
||||
default CompletableFuture<String> remoteGetStringAsync(final String schema, final String key) {
|
||||
return remoteGetAsync(schema, key, String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,14 +291,14 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default CompletableFuture<String> remoteGetStringAsync(final String key) {
|
||||
return remoteGetStringAsync(DEFAULT_HASH, key);
|
||||
return remoteGetStringAsync(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -307,7 +307,7 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> T remoteGetSet(
|
||||
final String hash,
|
||||
final String schema,
|
||||
final String key,
|
||||
final Type type,
|
||||
boolean nullable,
|
||||
@@ -327,14 +327,14 @@ public interface CachedManager {
|
||||
*/
|
||||
default <T> T remoteGetSet(
|
||||
final String key, final Type type, boolean nullable, Duration expire, ThrowSupplier<T> supplier) {
|
||||
return remoteGetSet(DEFAULT_HASH, key, type, nullable, expire, supplier);
|
||||
return remoteGetSet(DEFAULT_SCHEMA, key, type, nullable, expire, supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -343,7 +343,7 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> CompletableFuture<T> remoteGetSetAsync(
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -363,20 +363,20 @@ public interface CachedManager {
|
||||
*/
|
||||
default <T> CompletableFuture<T> remoteGetSetAsync(
|
||||
String key, Type type, boolean nullable, Duration expire, ThrowSupplier<CompletableFuture<T>> supplier) {
|
||||
return remoteGetSetAsync(DEFAULT_HASH, key, type, nullable, expire, supplier);
|
||||
return remoteGetSetAsync(DEFAULT_SCHEMA, key, type, nullable, expire, supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
public <T> void remoteSet(final String hash, final String key, final Type type, final T value, Duration expire);
|
||||
public <T> void remoteSet(final String schema, final String key, final Type type, final T value, Duration expire);
|
||||
|
||||
/**
|
||||
* 远程缓存数据
|
||||
@@ -388,19 +388,19 @@ public interface CachedManager {
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
default <T> void remoteSet(final String key, final Type type, final T value, Duration expire) {
|
||||
remoteSet(DEFAULT_HASH, key, type, value, expire);
|
||||
remoteSet(DEFAULT_SCHEMA, key, type, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程缓存字符串数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
default void remoteSetString(final String hash, final String key, final String value, Duration expire) {
|
||||
remoteSet(hash, key, String.class, value, expire);
|
||||
default void remoteSetString(final String schema, final String key, final String value, Duration expire) {
|
||||
remoteSet(schema, key, String.class, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,21 +411,21 @@ public interface CachedManager {
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
default void remoteSetString(final String key, final String value, Duration expire) {
|
||||
remoteSetString(DEFAULT_HASH, key, value, expire);
|
||||
remoteSetString(DEFAULT_SCHEMA, key, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
* @return void
|
||||
*/
|
||||
public <T> CompletableFuture<Void> remoteSetAsync(String hash, String key, Type type, T value, Duration expire);
|
||||
public <T> CompletableFuture<Void> remoteSetAsync(String schema, String key, Type type, T value, Duration expire);
|
||||
|
||||
/**
|
||||
* 远程异步缓存数据
|
||||
@@ -438,21 +438,21 @@ public interface CachedManager {
|
||||
* @return void
|
||||
*/
|
||||
default <T> CompletableFuture<Void> remoteSetAsync(String key, Type type, T value, Duration expire) {
|
||||
return remoteSetAsync(DEFAULT_HASH, key, type, value, expire);
|
||||
return remoteSetAsync(DEFAULT_SCHEMA, key, type, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步缓存字符串数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
* @return void
|
||||
*/
|
||||
default CompletableFuture<Void> remoteSetStringAsync(
|
||||
final String hash, final String key, final String value, Duration expire) {
|
||||
return remoteSetAsync(hash, key, String.class, value, expire);
|
||||
final String schema, final String key, final String value, Duration expire) {
|
||||
return remoteSetAsync(schema, key, String.class, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,17 +464,17 @@ public interface CachedManager {
|
||||
* @return void
|
||||
*/
|
||||
default CompletableFuture<Void> remoteSetStringAsync(final String key, final String value, Duration expire) {
|
||||
return remoteSetStringAsync(DEFAULT_HASH, key, value, expire);
|
||||
return remoteSetStringAsync(DEFAULT_SCHEMA, key, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
public long remoteDel(String hash, String key);
|
||||
public long remoteDel(String schema, String key);
|
||||
|
||||
/**
|
||||
* 远程删除缓存数据
|
||||
@@ -483,17 +483,17 @@ public interface CachedManager {
|
||||
* @return 删除数量
|
||||
*/
|
||||
default long remoteDel(String key) {
|
||||
return remoteDel(DEFAULT_HASH, key);
|
||||
return remoteDel(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
public CompletableFuture<Long> remoteDelAsync(String hash, String key);
|
||||
public CompletableFuture<Long> remoteDelAsync(String schema, String key);
|
||||
|
||||
/**
|
||||
* 远程异步删除缓存数据
|
||||
@@ -502,7 +502,7 @@ public interface CachedManager {
|
||||
* @return 删除数量
|
||||
*/
|
||||
default CompletableFuture<Long> remoteDelAsync(String key) {
|
||||
return remoteDelAsync(DEFAULT_HASH, key);
|
||||
return remoteDelAsync(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
// -------------------------------------- both缓存 --------------------------------------
|
||||
@@ -510,12 +510,12 @@ public interface CachedManager {
|
||||
* 本地或远程获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> T bothGet(final String hash, final String key, final Type type);
|
||||
public <T> T bothGet(final String schema, final String key, final Type type);
|
||||
|
||||
/**
|
||||
* 本地或远程获取缓存数据, 过期返回null
|
||||
@@ -526,18 +526,18 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default <T> T bothGet(final String key, final Type type) {
|
||||
return bothGet(DEFAULT_HASH, key, type);
|
||||
return bothGet(DEFAULT_SCHEMA, key, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地或远程获取字符串缓存数据, 过期返回null
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 数据值
|
||||
*/
|
||||
default String bothGetString(final String hash, final String key) {
|
||||
return bothGet(hash, key, String.class);
|
||||
default String bothGetString(final String schema, final String key) {
|
||||
return bothGet(schema, key, String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -547,19 +547,19 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default String bothGetString(final String key) {
|
||||
return bothGetString(DEFAULT_HASH, key);
|
||||
return bothGetString(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地或远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> CompletableFuture<T> bothGetAsync(final String hash, final String key, final Type type);
|
||||
public <T> CompletableFuture<T> bothGetAsync(final String schema, final String key, final Type type);
|
||||
|
||||
/**
|
||||
* 本地或远程异步获取缓存数据, 过期返回null
|
||||
@@ -570,18 +570,18 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default <T> CompletableFuture<T> bothGetAsync(final String key, final Type type) {
|
||||
return bothGetAsync(DEFAULT_HASH, key, type);
|
||||
return bothGetAsync(DEFAULT_SCHEMA, key, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地或远程异步获取字符串缓存数据, 过期返回null
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 数据值
|
||||
*/
|
||||
default CompletableFuture<String> bothGetStringAsync(final String hash, final String key) {
|
||||
return bothGetAsync(hash, key, String.class);
|
||||
default CompletableFuture<String> bothGetStringAsync(final String schema, final String key) {
|
||||
return bothGetAsync(schema, key, String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,14 +591,14 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
default CompletableFuture<String> bothGetStringAsync(final String key) {
|
||||
return bothGetStringAsync(DEFAULT_HASH, key);
|
||||
return bothGetStringAsync(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地或远程获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -608,7 +608,7 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> T bothGetSet(
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -635,14 +635,14 @@ public interface CachedManager {
|
||||
Duration localExpire,
|
||||
Duration remoteExpire,
|
||||
ThrowSupplier<T> supplier) {
|
||||
return bothGetSet(DEFAULT_HASH, key, type, nullable, localExpire, remoteExpire, supplier);
|
||||
return bothGetSet(DEFAULT_SCHEMA, key, type, nullable, localExpire, remoteExpire, supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地或远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -652,7 +652,7 @@ public interface CachedManager {
|
||||
* @return 数据值
|
||||
*/
|
||||
public <T> CompletableFuture<T> bothGetSetAsync(
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -679,14 +679,14 @@ public interface CachedManager {
|
||||
Duration localExpire,
|
||||
Duration remoteExpire,
|
||||
ThrowSupplier<CompletableFuture<T>> supplier) {
|
||||
return bothGetSetAsync(DEFAULT_HASH, key, type, nullable, localExpire, remoteExpire, supplier);
|
||||
return bothGetSetAsync(DEFAULT_SCHEMA, key, type, nullable, localExpire, remoteExpire, supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地和远程缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
@@ -694,7 +694,7 @@ public interface CachedManager {
|
||||
* @param remoteExpire 远程过期时长,Duration.ZERO为永不过期,为null表示不远程缓存
|
||||
*/
|
||||
public <T> void bothSet(
|
||||
final String hash,
|
||||
final String schema,
|
||||
final String key,
|
||||
final Type type,
|
||||
final T value,
|
||||
@@ -713,21 +713,21 @@ public interface CachedManager {
|
||||
*/
|
||||
default <T> void bothSet(
|
||||
final String key, final Type type, final T value, Duration localExpire, Duration remoteExpire) {
|
||||
bothSet(DEFAULT_HASH, key, type, value, localExpire, remoteExpire);
|
||||
bothSet(DEFAULT_SCHEMA, key, type, value, localExpire, remoteExpire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地和远程缓存字符串数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param value 数据值
|
||||
* @param localExpire 本地过期时长,Duration.ZERO为永不过期,为null表示不本地缓存
|
||||
* @param remoteExpire 远程过期时长,Duration.ZERO为永不过期,为null表示不远程缓存
|
||||
*/
|
||||
default void bothSetString(
|
||||
final String hash, final String key, final String value, Duration localExpire, Duration remoteExpire) {
|
||||
bothSet(hash, key, String.class, value, localExpire, remoteExpire);
|
||||
final String schema, final String key, final String value, Duration localExpire, Duration remoteExpire) {
|
||||
bothSet(schema, key, String.class, value, localExpire, remoteExpire);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -739,14 +739,14 @@ public interface CachedManager {
|
||||
* @param remoteExpire 远程过期时长,Duration.ZERO为永不过期,为null表示不远程缓存
|
||||
*/
|
||||
default void bothSetString(final String key, final String value, Duration localExpire, Duration remoteExpire) {
|
||||
bothSet(DEFAULT_HASH, key, String.class, value, localExpire, remoteExpire);
|
||||
bothSet(DEFAULT_SCHEMA, key, String.class, value, localExpire, remoteExpire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地和远程异步缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
@@ -755,7 +755,7 @@ public interface CachedManager {
|
||||
* @return void
|
||||
*/
|
||||
public <T> CompletableFuture<Void> bothSetAsync(
|
||||
String hash, String key, Type type, T value, Duration localExpire, Duration remoteExpire);
|
||||
String schema, String key, Type type, T value, Duration localExpire, Duration remoteExpire);
|
||||
|
||||
/**
|
||||
* 本地和远程异步缓存数据
|
||||
@@ -770,13 +770,13 @@ public interface CachedManager {
|
||||
*/
|
||||
default <T> CompletableFuture<Void> bothSetAsync(
|
||||
String key, Type type, T value, Duration localExpire, Duration remoteExpire) {
|
||||
return bothSetAsync(DEFAULT_HASH, key, type, value, localExpire, remoteExpire);
|
||||
return bothSetAsync(DEFAULT_SCHEMA, key, type, value, localExpire, remoteExpire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地和远程异步缓存字符串数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param value 数据值
|
||||
* @param localExpire 本地过期时长,Duration.ZERO为永不过期,为null表示不本地缓存
|
||||
@@ -784,8 +784,8 @@ public interface CachedManager {
|
||||
* @return void
|
||||
*/
|
||||
default CompletableFuture<Void> bothSetStringAsync(
|
||||
String hash, String key, String value, Duration localExpire, Duration remoteExpire) {
|
||||
return bothSetAsync(hash, key, String.class, value, localExpire, remoteExpire);
|
||||
String schema, String key, String value, Duration localExpire, Duration remoteExpire) {
|
||||
return bothSetAsync(schema, key, String.class, value, localExpire, remoteExpire);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -799,17 +799,17 @@ public interface CachedManager {
|
||||
*/
|
||||
default CompletableFuture<Void> bothSetStringAsync(
|
||||
String key, String value, Duration localExpire, Duration remoteExpire) {
|
||||
return bothSetAsync(DEFAULT_HASH, key, String.class, value, localExpire, remoteExpire);
|
||||
return bothSetAsync(DEFAULT_SCHEMA, key, String.class, value, localExpire, remoteExpire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地和远程删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
public long bothDel(String hash, String key);
|
||||
public long bothDel(String schema, String key);
|
||||
|
||||
/**
|
||||
* 本地和远程删除缓存数据
|
||||
@@ -818,17 +818,17 @@ public interface CachedManager {
|
||||
* @return 删除数量
|
||||
*/
|
||||
default long bothDel(String key) {
|
||||
return bothDel(DEFAULT_HASH, key);
|
||||
return bothDel(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地和远程异步删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
public CompletableFuture<Long> bothDelAsync(String hash, String key);
|
||||
public CompletableFuture<Long> bothDelAsync(String schema, String key);
|
||||
|
||||
/**
|
||||
* 本地和远程异步删除缓存数据
|
||||
@@ -837,6 +837,6 @@ public interface CachedManager {
|
||||
* @return 删除数量
|
||||
*/
|
||||
default CompletableFuture<Long> bothDelAsync(String key) {
|
||||
return bothDelAsync(DEFAULT_HASH, key);
|
||||
return bothDelAsync(DEFAULT_SCHEMA, key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +96,9 @@ public class CachedAction {
|
||||
}
|
||||
|
||||
void init(ResourceFactory resourceFactory, Object service) {
|
||||
this.hash = cached.getHash().trim().isEmpty() || CachedManager.DEFAULT_HASH.equals(cached.getHash())
|
||||
? CachedManager.DEFAULT_HASH
|
||||
: environment.getPropertyValue(cached.getHash());
|
||||
this.hash = cached.getSchema().trim().isEmpty() || CachedManager.DEFAULT_SCHEMA.equals(cached.getSchema())
|
||||
? CachedManager.DEFAULT_SCHEMA
|
||||
: environment.getPropertyValue(cached.getSchema());
|
||||
String key = environment.getPropertyValue(cached.getKey());
|
||||
this.templetKey = key;
|
||||
if (key.startsWith("@")) { // 动态加载缓存key生成器
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CachedEntry {
|
||||
|
||||
private String key;
|
||||
|
||||
private String hash;
|
||||
private String schema;
|
||||
|
||||
private String localExpire;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CachedEntry {
|
||||
|
||||
public CachedEntry(DynForCached cached) {
|
||||
this.key = cached.key();
|
||||
this.hash = cached.hash();
|
||||
this.schema = cached.schema();
|
||||
this.localExpire = cached.localExpire();
|
||||
this.remoteExpire = cached.remoteExpire();
|
||||
this.timeUnit = cached.timeUnit();
|
||||
@@ -43,7 +43,7 @@ public class CachedEntry {
|
||||
|
||||
public CachedEntry(Cached cached) {
|
||||
this.key = cached.key();
|
||||
this.hash = cached.hash();
|
||||
this.schema = cached.schema();
|
||||
this.localExpire = cached.localExpire();
|
||||
this.remoteExpire = cached.remoteExpire();
|
||||
this.timeUnit = cached.timeUnit();
|
||||
@@ -54,8 +54,8 @@ public class CachedEntry {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
public String getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
public String getLocalExpire() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.redkale.util.MultiHashKey;
|
||||
/**
|
||||
* 缓存key生成器
|
||||
*
|
||||
* @see org.redkale.cache.Cached#key()
|
||||
* @see org.redkale.cached.Cached#key()
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
@@ -22,8 +22,8 @@ public interface CachedKeyGenerator {
|
||||
/**
|
||||
* 根据service和方法名生成key
|
||||
*
|
||||
* @param target Service对象
|
||||
* @param action CacheAction对象
|
||||
* @param target 依附对象
|
||||
* @param action {@link org.redkale.cached.spi.CachedAction}对象
|
||||
* @param params 参数值
|
||||
* @return key值
|
||||
*/
|
||||
@@ -32,15 +32,15 @@ public interface CachedKeyGenerator {
|
||||
/**
|
||||
* 生成器的名字
|
||||
*
|
||||
* @see org.redkale.cache.Cached#key()
|
||||
* @see org.redkale.cached.Cached#key()
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
public String name();
|
||||
|
||||
/**
|
||||
* 根据MultiHashKey生成一个CacheKeyGenerator
|
||||
* @param key MultiHashKey 不能为空
|
||||
* 根据MultiHashKey生成一个CachedKeyGenerator
|
||||
* @param key {@link org.redkale.util.MultiHashKey} 不能为空
|
||||
* @return CachedKeyGenerator
|
||||
*/
|
||||
public static CachedKeyGenerator create(MultiHashKey key) {
|
||||
|
||||
@@ -58,11 +58,11 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
// 本地缓存Source
|
||||
protected final CacheMemorySource localSource = new CacheMemorySource("cache-local");
|
||||
|
||||
// 缓存hash集合, 用于定时遍历删除过期数据
|
||||
// 缓存schema集合, 用于定时遍历删除过期数据
|
||||
protected final ConcurrentSkipListSet<String> hashNames = new ConcurrentSkipListSet<>();
|
||||
|
||||
// 缓存无效时使用的同步锁
|
||||
private final ConcurrentHashMap<String, CachedValue> syncLock = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, CachedValue> syncLockMap = new ConcurrentHashMap<>();
|
||||
|
||||
// 缓存无效时使用的异步锁
|
||||
private final ConcurrentHashMap<String, CachedAsyncLock> asyncLockMap = new ConcurrentHashMap<>();
|
||||
@@ -132,8 +132,8 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public CachedManagerService addHash(String hash) {
|
||||
this.hashNames.add(hash);
|
||||
public CachedManagerService addSchema(String schema) {
|
||||
this.hashNames.add(schema);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -158,22 +158,22 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 本地获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
@Override
|
||||
public <T> T localGet(final String hash, final String key, final Type type) {
|
||||
public <T> T localGet(final String schema, final String key, final Type type) {
|
||||
checkEnable();
|
||||
return CachedValue.get(localSource.get(idFor(hash, key), loadCacheType(type)));
|
||||
return CachedValue.get(localSource.get(idFor(schema, key), loadCacheType(type)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -183,7 +183,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
*/
|
||||
@Override
|
||||
public <T> T localGetSet(
|
||||
final String hash,
|
||||
final String schema,
|
||||
final String key,
|
||||
final Type type,
|
||||
boolean nullable,
|
||||
@@ -192,7 +192,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
return getSet(
|
||||
(id, ex, ct) -> localSource.get(id, ct),
|
||||
this::localSetCache,
|
||||
hash,
|
||||
schema,
|
||||
key,
|
||||
type,
|
||||
nullable,
|
||||
@@ -204,7 +204,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 本地异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -214,7 +214,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
*/
|
||||
@Override
|
||||
public <T> CompletableFuture<T> localGetSetAsync(
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -223,7 +223,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
return getSetAsync(
|
||||
(id, ex, ct) -> localSource.getAsync(id, ct),
|
||||
this::localSetCacheAsync,
|
||||
hash,
|
||||
schema,
|
||||
key,
|
||||
type,
|
||||
nullable,
|
||||
@@ -235,28 +235,28 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 本地缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
@Override
|
||||
public <T> void localSet(String hash, String key, Type type, T value, Duration expire) {
|
||||
setCache(localSource, hash, key, type, value, expire);
|
||||
public <T> void localSet(String schema, String key, Type type, T value, Duration expire) {
|
||||
setCache(localSource, schema, key, type, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
@Override
|
||||
public long localDel(String hash, String key) {
|
||||
public long localDel(String schema, String key) {
|
||||
checkEnable();
|
||||
return localSource.del(idFor(hash, key));
|
||||
return localSource.del(idFor(schema, key));
|
||||
}
|
||||
|
||||
// -------------------------------------- 远程缓存 --------------------------------------
|
||||
@@ -264,30 +264,30 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 远程获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
@Override
|
||||
public <T> T remoteGet(final String hash, final String key, final Type type) {
|
||||
public <T> T remoteGet(final String schema, final String key, final Type type) {
|
||||
checkEnable();
|
||||
return CachedValue.get(remoteSource.get(idFor(hash, key), loadCacheType(type)));
|
||||
return CachedValue.get(remoteSource.get(idFor(schema, key), loadCacheType(type)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
@Override
|
||||
public <T> CompletableFuture<T> remoteGetAsync(final String hash, final String key, final Type type) {
|
||||
public <T> CompletableFuture<T> remoteGetAsync(final String schema, final String key, final Type type) {
|
||||
checkEnable();
|
||||
CompletableFuture<CachedValue<T>> future = remoteSource.getAsync(idFor(hash, key), loadCacheType(type));
|
||||
CompletableFuture<CachedValue<T>> future = remoteSource.getAsync(idFor(schema, key), loadCacheType(type));
|
||||
return future.thenApply(CachedValue::get);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 远程获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -305,7 +305,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
*/
|
||||
@Override
|
||||
public <T> T remoteGetSet(
|
||||
final String hash,
|
||||
final String schema,
|
||||
final String key,
|
||||
final Type type,
|
||||
boolean nullable,
|
||||
@@ -314,7 +314,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
return getSet(
|
||||
(id, ex, ct) -> remoteSource.get(id, ct),
|
||||
this::remoteSetCache,
|
||||
hash,
|
||||
schema,
|
||||
key,
|
||||
type,
|
||||
nullable,
|
||||
@@ -326,7 +326,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -336,7 +336,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
*/
|
||||
@Override
|
||||
public <T> CompletableFuture<T> remoteGetSetAsync(
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -345,7 +345,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
return getSetAsync(
|
||||
(id, ex, ct) -> remoteSource.getAsync(id, ct),
|
||||
this::remoteSetCacheAsync,
|
||||
hash,
|
||||
schema,
|
||||
key,
|
||||
type,
|
||||
nullable,
|
||||
@@ -357,56 +357,56 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 远程缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
@Override
|
||||
public <T> void remoteSet(final String hash, final String key, final Type type, final T value, Duration expire) {
|
||||
setCache(remoteSource, hash, key, type, value, expire);
|
||||
public <T> void remoteSet(final String schema, final String key, final Type type, final T value, Duration expire) {
|
||||
setCache(remoteSource, schema, key, type, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
*/
|
||||
@Override
|
||||
public <T> CompletableFuture<Void> remoteSetAsync(String hash, String key, Type type, T value, Duration expire) {
|
||||
return setCacheAsync(remoteSource, hash, key, type, value, expire);
|
||||
public <T> CompletableFuture<Void> remoteSetAsync(String schema, String key, Type type, T value, Duration expire) {
|
||||
return setCacheAsync(remoteSource, schema, key, type, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
@Override
|
||||
public long remoteDel(String hash, String key) {
|
||||
public long remoteDel(String schema, String key) {
|
||||
checkEnable();
|
||||
return remoteSource.del(idFor(hash, key));
|
||||
return remoteSource.del(idFor(schema, key));
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
@Override
|
||||
public CompletableFuture<Long> remoteDelAsync(String hash, String key) {
|
||||
public CompletableFuture<Long> remoteDelAsync(String schema, String key) {
|
||||
checkEnable();
|
||||
return remoteSource.delAsync(idFor(hash, key));
|
||||
return remoteSource.delAsync(idFor(schema, key));
|
||||
}
|
||||
|
||||
// -------------------------------------- both缓存 --------------------------------------
|
||||
@@ -414,35 +414,35 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 远程获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
@Override
|
||||
public <T> T bothGet(final String hash, final String key, final Type type) {
|
||||
return CachedValue.get(bothGetCache(hash, key, (Duration) null, type));
|
||||
public <T> T bothGet(final String schema, final String key, final Type type) {
|
||||
return CachedValue.get(bothGetCache(schema, key, (Duration) null, type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
@Override
|
||||
public <T> CompletableFuture<T> bothGetAsync(final String hash, final String key, final Type type) {
|
||||
return bothGetCacheAsync(hash, key, (Duration) null, type).thenApply(CachedValue::get);
|
||||
public <T> CompletableFuture<T> bothGetAsync(final String schema, final String key, final Type type) {
|
||||
return bothGetCacheAsync(schema, key, (Duration) null, type).thenApply(CachedValue::get);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -453,7 +453,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
*/
|
||||
@Override
|
||||
public <T> T bothGetSet(
|
||||
final String hash,
|
||||
final String schema,
|
||||
final String key,
|
||||
final Type type,
|
||||
boolean nullable,
|
||||
@@ -471,11 +471,11 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
}
|
||||
if (remoteExpire == null) { // 只有本地缓存
|
||||
Objects.requireNonNull(localExpire);
|
||||
return localGetSet(hash, key, type, nullable, localExpire, supplier);
|
||||
return localGetSet(schema, key, type, nullable, localExpire, supplier);
|
||||
}
|
||||
if (localExpire == null) { // 只有远程缓存
|
||||
Objects.requireNonNull(remoteExpire);
|
||||
return remoteGetSet(hash, key, type, nullable, remoteExpire, supplier);
|
||||
return remoteGetSet(schema, key, type, nullable, remoteExpire, supplier);
|
||||
}
|
||||
return getSet(
|
||||
this::bothGetCache,
|
||||
@@ -485,7 +485,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
remoteSetCache(i, remoteExpire, t, v);
|
||||
}
|
||||
},
|
||||
hash,
|
||||
schema,
|
||||
key,
|
||||
type,
|
||||
nullable,
|
||||
@@ -497,7 +497,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -508,7 +508,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
*/
|
||||
@Override
|
||||
public <T> CompletableFuture<T> bothGetSetAsync(
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -524,11 +524,11 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
}
|
||||
if (remoteExpire == null) { // 只有本地缓存
|
||||
Objects.requireNonNull(localExpire);
|
||||
return localGetSetAsync(hash, key, type, nullable, localExpire, supplier);
|
||||
return localGetSetAsync(schema, key, type, nullable, localExpire, supplier);
|
||||
}
|
||||
if (localExpire == null) { // 只有远程缓存
|
||||
Objects.requireNonNull(remoteExpire);
|
||||
return remoteGetSetAsync(hash, key, type, nullable, remoteExpire, supplier);
|
||||
return remoteGetSetAsync(schema, key, type, nullable, remoteExpire, supplier);
|
||||
}
|
||||
return getSetAsync(
|
||||
this::bothGetCacheAsync,
|
||||
@@ -540,7 +540,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
},
|
||||
hash,
|
||||
schema,
|
||||
key,
|
||||
type,
|
||||
nullable,
|
||||
@@ -552,7 +552,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 远程缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
@@ -561,7 +561,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
*/
|
||||
@Override
|
||||
public <T> void bothSet(
|
||||
final String hash,
|
||||
final String schema,
|
||||
final String key,
|
||||
final Type type,
|
||||
final T value,
|
||||
@@ -569,13 +569,13 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
Duration remoteExpire) {
|
||||
checkEnable();
|
||||
if (localExpire != null) {
|
||||
setCache(localSource, hash, key, type, value, localExpire);
|
||||
setCache(localSource, schema, key, type, value, localExpire);
|
||||
}
|
||||
if (remoteExpire != null && remoteSource != null) {
|
||||
setCache(remoteSource, hash, key, type, value, remoteExpire);
|
||||
setCache(remoteSource, schema, key, type, value, remoteExpire);
|
||||
}
|
||||
if (remoteSource != null && broadcastable) {
|
||||
remoteSource.publish(CACHE_CHANNEL_TOPIC, new CachedEventMessage(idFor(hash, key)));
|
||||
remoteSource.publish(CACHE_CHANNEL_TOPIC, new CachedEventMessage(idFor(schema, key)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* 远程异步缓存数据
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param value 数据值
|
||||
@@ -593,18 +593,18 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
*/
|
||||
@Override
|
||||
public <T> CompletableFuture<Void> bothSetAsync(
|
||||
String hash, String key, Type type, T value, Duration localExpire, Duration remoteExpire) {
|
||||
String schema, String key, Type type, T value, Duration localExpire, Duration remoteExpire) {
|
||||
checkEnable();
|
||||
if (localExpire != null) {
|
||||
setCache(localSource, hash, key, type, value, localExpire);
|
||||
setCache(localSource, schema, key, type, value, localExpire);
|
||||
}
|
||||
CompletableFuture<Void> future = CompletableFuture.completedFuture(null);
|
||||
if (remoteSource != null && remoteExpire != null) {
|
||||
future = setCacheAsync(remoteSource, hash, key, type, value, remoteExpire);
|
||||
future = setCacheAsync(remoteSource, schema, key, type, value, remoteExpire);
|
||||
}
|
||||
if (remoteSource != null && broadcastable) {
|
||||
future = future.thenCompose(r -> remoteSource
|
||||
.publishAsync(CACHE_CHANNEL_TOPIC, new CachedEventMessage(idFor(hash, key)))
|
||||
.publishAsync(CACHE_CHANNEL_TOPIC, new CachedEventMessage(idFor(schema, key)))
|
||||
.thenApply(n -> r));
|
||||
}
|
||||
return future;
|
||||
@@ -613,14 +613,14 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
/**
|
||||
* 远程删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
@Override
|
||||
public long bothDel(String hash, String key) {
|
||||
public long bothDel(String schema, String key) {
|
||||
checkEnable();
|
||||
String id = idFor(hash, key);
|
||||
String id = idFor(schema, key);
|
||||
long v = localSource.del(id);
|
||||
if (remoteSource != null) {
|
||||
v = remoteSource.del(id);
|
||||
@@ -634,14 +634,14 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
/**
|
||||
* 远程异步删除缓存数据
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return 删除数量
|
||||
*/
|
||||
@Override
|
||||
public CompletableFuture<Long> bothDelAsync(String hash, String key) {
|
||||
public CompletableFuture<Long> bothDelAsync(String schema, String key) {
|
||||
checkEnable();
|
||||
String id = idFor(hash, key);
|
||||
String id = idFor(schema, key);
|
||||
long v = localSource.del(id); // 内存操作,无需异步
|
||||
if (remoteSource != null) {
|
||||
return remoteSource.delAsync(id).thenCompose(r -> {
|
||||
@@ -663,7 +663,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* @param <T> 泛型
|
||||
* @param getter 获取数据函数
|
||||
* @param setter 设置数据函数
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -674,7 +674,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
protected <T> T getSet(
|
||||
GetterFunc<CachedValue<T>> getter,
|
||||
SetterSyncFunc setter,
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -684,7 +684,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
Objects.requireNonNull(expire);
|
||||
Objects.requireNonNull(supplier);
|
||||
final Type cacheType = loadCacheType(type);
|
||||
final String id = idFor(hash, key);
|
||||
final String id = idFor(schema, key);
|
||||
CachedValue<T> cacheVal = getter.get(id, expire, cacheType);
|
||||
if (CachedValue.isValid(cacheVal)) {
|
||||
return cacheVal.getVal();
|
||||
@@ -707,11 +707,11 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
}
|
||||
return newCacheVal;
|
||||
};
|
||||
cacheVal = syncLock.computeIfAbsent(id, func);
|
||||
cacheVal = syncLockMap.computeIfAbsent(id, func);
|
||||
try {
|
||||
return CachedValue.get(cacheVal);
|
||||
} finally {
|
||||
syncLock.remove(id);
|
||||
syncLockMap.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,7 +721,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
* @param <T> 泛型
|
||||
* @param getter 获取数据函数
|
||||
* @param setter 设置数据函数
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param type 数据类型
|
||||
* @param nullable 是否缓存null值
|
||||
@@ -732,7 +732,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
protected <T> CompletableFuture<T> getSetAsync(
|
||||
GetterFunc<CompletableFuture<CachedValue<T>>> getter,
|
||||
SetterAsyncFunc setter,
|
||||
String hash,
|
||||
String schema,
|
||||
String key,
|
||||
Type type,
|
||||
boolean nullable,
|
||||
@@ -741,7 +741,7 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
checkEnable();
|
||||
Objects.requireNonNull(supplier);
|
||||
final Type cacheType = loadCacheType(type);
|
||||
final String id = idFor(hash, key);
|
||||
final String id = idFor(schema, key);
|
||||
CompletableFuture<CachedValue<T>> sourceFuture = getter.get(id, expire, cacheType);
|
||||
return sourceFuture.thenCompose(val -> {
|
||||
if (CachedValue.isValid(val)) {
|
||||
@@ -813,32 +813,32 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> void setCache(CacheSource source, String hash, String key, Type type, T value, Duration expire) {
|
||||
setCache(source, idFor(hash, key), expire, loadCacheType(type, value), CachedValue.create(value));
|
||||
protected <T> void setCache(CacheSource source, String schema, String key, Type type, T value, Duration expire) {
|
||||
setCache(source, idFor(schema, key), expire, loadCacheType(type, value), CachedValue.create(value));
|
||||
}
|
||||
|
||||
protected <T> CompletableFuture<Void> setCacheAsync(
|
||||
CacheSource source, String hash, String key, Type type, T value, Duration expire) {
|
||||
return setCacheAsync(source, idFor(hash, key), expire, loadCacheType(type, value), CachedValue.create(value));
|
||||
CacheSource source, String schema, String key, Type type, T value, Duration expire) {
|
||||
return setCacheAsync(source, idFor(schema, key), expire, loadCacheType(type, value), CachedValue.create(value));
|
||||
}
|
||||
|
||||
protected <T> CachedValue<T> bothGetCache(String hash, String key, Duration expire, Type type) {
|
||||
return bothGetCache(idFor(hash, key), expire, loadCacheType(type));
|
||||
protected <T> CachedValue<T> bothGetCache(String schema, String key, Duration expire, Type type) {
|
||||
return bothGetCache(idFor(schema, key), expire, loadCacheType(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程异步获取缓存数据, 过期返回null
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @param expire 过期时长,Duration.ZERO为永不过期
|
||||
* @param type 数据类型
|
||||
* @return 数据值
|
||||
*/
|
||||
protected <T> CompletableFuture<CachedValue<T>> bothGetCacheAsync(
|
||||
final String hash, final String key, Duration expire, final Type type) {
|
||||
return bothGetCacheAsync(idFor(hash, key), expire, loadCacheType(type));
|
||||
final String schema, final String key, Duration expire, final Type type) {
|
||||
return bothGetCacheAsync(idFor(schema, key), expire, loadCacheType(type));
|
||||
}
|
||||
|
||||
protected <T> CachedValue<T> bothGetCache(final String id, final Duration expire, final Type cacheType) {
|
||||
@@ -895,12 +895,12 @@ public class CachedManagerService implements CachedManager, Service {
|
||||
/**
|
||||
* 创建一个锁key
|
||||
*
|
||||
* @param hash 缓存hash
|
||||
* @param schema 缓存schema
|
||||
* @param key 缓存键
|
||||
* @return key
|
||||
*/
|
||||
protected String idFor(String hash, String key) {
|
||||
return hash + ':' + key;
|
||||
protected String idFor(String schema, String key) {
|
||||
return schema + ':' + key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
*/
|
||||
package org.redkale.cached.spi;
|
||||
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.redkale.service.LoadMode;
|
||||
|
||||
/**
|
||||
* {@link org.redkale.cache.Cached}注解的动态扩展版,会多一个字段信息 用于识别方法是否已经动态处理过
|
||||
* {@link org.redkale.cached.Cached}注解的动态扩展版,会多一个字段信息 用于识别方法是否已经动态处理过
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
@@ -27,7 +26,7 @@ public @interface DynForCached {
|
||||
|
||||
String key();
|
||||
|
||||
String hash();
|
||||
String schema();
|
||||
|
||||
String localExpire();
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.cached.spi.CachedAction;
|
||||
import org.redkale.cached.spi.DynForCached;
|
||||
import org.redkale.net.sncp.Sncp.SncpDyn;
|
||||
import org.redkale.util.AnyValue;
|
||||
import org.redkale.util.RedkaleException;
|
||||
import org.redkale.util.ThrowSupplier;
|
||||
import org.redkale.cached.spi.DynForCached;
|
||||
|
||||
@Resource(name = "")
|
||||
@SncpDyn(remote = false, type = CachedInstance.class)
|
||||
@@ -27,25 +27,25 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
|
||||
private String _redkale_mq;
|
||||
|
||||
private CachedAction _redkale_getNameCacheAction1;
|
||||
private CachedAction _redkale_getNameCachedAction1;
|
||||
|
||||
private CachedAction _redkale_getInfoCacheAction2;
|
||||
private CachedAction _redkale_getInfoCachedAction2;
|
||||
|
||||
private CachedAction _redkale_getNameAsyncCacheAction3;
|
||||
private CachedAction _redkale_getNameAsyncCachedAction3;
|
||||
|
||||
private CachedAction _redkale_getInfo2AsyncCacheAction4;
|
||||
private CachedAction _redkale_getInfo2AsyncCachedAction4;
|
||||
|
||||
private CachedAction _redkale_getName2AsyncCacheAction5;
|
||||
private CachedAction _redkale_getName2AsyncCachedAction5;
|
||||
|
||||
private CachedAction _redkale_getInfoAsyncCacheAction6;
|
||||
private CachedAction _redkale_getInfoAsyncCachedAction6;
|
||||
|
||||
private CachedAction _redkale_getName2CacheAction7;
|
||||
private CachedAction _redkale_getName2CachedAction7;
|
||||
|
||||
public _DynLocalCacheInstance() {}
|
||||
|
||||
@DynForCached(
|
||||
dynField = "_redkale_getNameCacheAction1",
|
||||
hash = "",
|
||||
dynField = "_redkale_getNameCachedAction1",
|
||||
schema = "",
|
||||
key = "name",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
@@ -53,7 +53,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
localExpire = "30")
|
||||
public String getName() {
|
||||
ThrowSupplier<String> supplier = () -> this.getName_afterCache();
|
||||
return _redkale_getNameCacheAction1.get(supplier);
|
||||
return _redkale_getNameCachedAction1.get(supplier);
|
||||
}
|
||||
|
||||
private String getName_afterCache() {
|
||||
@@ -61,8 +61,8 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
}
|
||||
|
||||
@DynForCached(
|
||||
dynField = "_redkale_getInfoCacheAction2",
|
||||
hash = "",
|
||||
dynField = "_redkale_getInfoCachedAction2",
|
||||
schema = "",
|
||||
key = "info_#{id}_file#{files.one}",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
@@ -70,7 +70,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
localExpire = "30")
|
||||
public File getInfo(CachedInstance.ParamBean bean, int id, List<String> idList, Map<String, File> files) {
|
||||
ThrowSupplier<File> supplier = () -> this.getInfo_afterCache(bean, id, idList, files);
|
||||
return _redkale_getInfoCacheAction2.get(supplier);
|
||||
return _redkale_getInfoCachedAction2.get(supplier);
|
||||
}
|
||||
|
||||
private File getInfo_afterCache(
|
||||
@@ -79,8 +79,8 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
}
|
||||
|
||||
@DynForCached(
|
||||
dynField = "_redkale_getNameAsyncCacheAction3",
|
||||
hash = "",
|
||||
dynField = "_redkale_getNameAsyncCachedAction3",
|
||||
schema = "",
|
||||
key = "name",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
@@ -88,7 +88,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
localExpire = "30")
|
||||
public CompletableFuture<String> getNameAsync() {
|
||||
ThrowSupplier<CompletableFuture<String>> supplier = () -> this.getNameAsync_afterCache();
|
||||
return _redkale_getNameAsyncCacheAction3.get(supplier);
|
||||
return _redkale_getNameAsyncCachedAction3.get(supplier);
|
||||
}
|
||||
|
||||
private CompletableFuture<String> getNameAsync_afterCache() {
|
||||
@@ -96,8 +96,8 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
}
|
||||
|
||||
@DynForCached(
|
||||
dynField = "_redkale_getInfo2AsyncCacheAction4",
|
||||
hash = "",
|
||||
dynField = "_redkale_getInfo2AsyncCachedAction4",
|
||||
schema = "",
|
||||
key = "info_#{id}_file#{files.one}",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
@@ -108,7 +108,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
throws IOException, InstantiationException {
|
||||
ThrowSupplier<CompletableFuture<Map<String, Integer>>> supplier =
|
||||
() -> this.getInfo2Async_afterCache(bean, id, idList, files);
|
||||
return _redkale_getInfo2AsyncCacheAction4.get(supplier, bean, id, idList, files);
|
||||
return _redkale_getInfo2AsyncCachedAction4.get(supplier, bean, id, idList, files);
|
||||
}
|
||||
|
||||
private CompletableFuture<Map<String, Integer>> getInfo2Async_afterCache(
|
||||
@@ -118,8 +118,8 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
}
|
||||
|
||||
@DynForCached(
|
||||
dynField = "_redkale_getName2AsyncCacheAction5",
|
||||
hash = "",
|
||||
dynField = "_redkale_getName2AsyncCachedAction5",
|
||||
schema = "",
|
||||
key = "name",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
@@ -127,7 +127,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
localExpire = "30")
|
||||
public CompletableFuture<String> getName2Async() throws IOException, InstantiationException {
|
||||
ThrowSupplier<CompletableFuture<String>> supplier = () -> this.getName2Async_afterCache();
|
||||
return _redkale_getName2AsyncCacheAction5.get(supplier);
|
||||
return _redkale_getName2AsyncCachedAction5.get(supplier);
|
||||
}
|
||||
|
||||
private CompletableFuture<String> getName2Async_afterCache() throws IOException, InstantiationException {
|
||||
@@ -135,8 +135,8 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
}
|
||||
|
||||
@DynForCached(
|
||||
dynField = "_redkale_getInfoAsyncCacheAction6",
|
||||
hash = "",
|
||||
dynField = "_redkale_getInfoAsyncCachedAction6",
|
||||
schema = "",
|
||||
key = "info_#{id}_file#{files.one}",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
@@ -145,7 +145,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
public CompletableFuture<File> getInfoAsync(
|
||||
CachedInstance.ParamBean bean, int id, List<String> idList, Map<String, File> files) {
|
||||
ThrowSupplier<CompletableFuture<File>> supplier = () -> this.getInfoAsync_afterCache(bean, id, idList, files);
|
||||
return _redkale_getInfoAsyncCacheAction6.get(supplier, bean, id, idList, files);
|
||||
return _redkale_getInfoAsyncCachedAction6.get(supplier, bean, id, idList, files);
|
||||
}
|
||||
|
||||
private CompletableFuture<File> getInfoAsync_afterCache(
|
||||
@@ -154,8 +154,8 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
}
|
||||
|
||||
@DynForCached(
|
||||
dynField = "_redkale_getName2CacheAction7",
|
||||
hash = "",
|
||||
dynField = "_redkale_getName2CachedAction7",
|
||||
schema = "",
|
||||
key = "name",
|
||||
nullable = false,
|
||||
timeUnit = TimeUnit.SECONDS,
|
||||
@@ -163,7 +163,7 @@ public class _DynLocalCacheInstance extends CachedInstance {
|
||||
localExpire = "30")
|
||||
public String getName2() throws RedkaleException {
|
||||
ThrowSupplier<String> supplier = () -> this.getName2_afterCache();
|
||||
return _redkale_getName2CacheAction7.get(supplier);
|
||||
return _redkale_getName2CachedAction7.get(supplier);
|
||||
}
|
||||
|
||||
private String getName2_afterCache() throws RedkaleException {
|
||||
|
||||
Reference in New Issue
Block a user