diff --git a/docs/cached.md b/docs/cached.md index 3cfdcdf72..2290977d1 100644 --- a/docs/cached.md +++ b/docs/cached.md @@ -56,7 +56,8 @@ - + ``` \ No newline at end of file diff --git a/src/main/java/org/redkale/cache/Cached.java b/src/main/java/org/redkale/cache/Cached.java index ff2ef76cb..d3382db51 100644 --- a/src/main/java/org/redkale/cache/Cached.java +++ b/src/main/java/org/redkale/cache/Cached.java @@ -27,7 +27,7 @@ public @interface Cached { /** * 缓存的key,支持参数动态组合,比如"key_#{id}"
- * '@'开头的key值视为CacheKeyGenerator对象名称
+ * '@'开头的key值视为CacheKeyGenerator对象名称
* * @see org.redkale.cache.spi.CacheKeyGenerator#name() * diff --git a/src/main/java/org/redkale/cache/spi/CacheManagerService.java b/src/main/java/org/redkale/cache/spi/CacheManagerService.java index 100630d29..61d45fd0e 100644 --- a/src/main/java/org/redkale/cache/spi/CacheManagerService.java +++ b/src/main/java/org/redkale/cache/spi/CacheManagerService.java @@ -195,7 +195,15 @@ public class CacheManagerService implements CacheManager, Service { boolean nullable, Duration expire, ThrowSupplier supplier) { - return getSet(this::localGetCache, this::localSetCache, hash, key, type, nullable, expire, supplier); + return getSet( + (id, ex, ct) -> localSource.get(id, ct), + this::localSetCache, + hash, + key, + type, + nullable, + expire, + supplier); } /** @@ -219,7 +227,14 @@ public class CacheManagerService implements CacheManager, Service { Duration expire, ThrowSupplier> supplier) { return getSetAsync( - this::localGetCacheAsync, this::localSetCacheAsync, hash, key, type, nullable, expire, supplier); + (id, ex, ct) -> localSource.getAsync(id, ct), + this::localSetCacheAsync, + hash, + key, + type, + nullable, + expire, + supplier); } /** @@ -302,7 +317,15 @@ public class CacheManagerService implements CacheManager, Service { boolean nullable, Duration expire, ThrowSupplier supplier) { - return getSet(this::remoteGetCache, this::remoteSetCache, hash, key, type, nullable, expire, supplier); + return getSet( + (id, ex, ct) -> remoteSource.get(id, ct), + this::remoteSetCache, + hash, + key, + type, + nullable, + expire, + supplier); } /** @@ -326,7 +349,14 @@ public class CacheManagerService implements CacheManager, Service { Duration expire, ThrowSupplier> supplier) { return getSetAsync( - this::remoteGetCacheAsync, this::remoteSetCacheAsync, hash, key, type, nullable, expire, supplier); + (id, ex, ct) -> remoteSource.getAsync(id, ct), + this::remoteSetCacheAsync, + hash, + key, + type, + nullable, + expire, + supplier); } /** @@ -808,6 +838,7 @@ public class CacheManagerService implements CacheManager, Service { * @param 泛型 * @param hash 缓存hash * @param key 缓存键 + * @param expire 过期时长,Duration.ZERO为永不过期 * @param type 数据类型 * @return 数据值 */ @@ -833,27 +864,12 @@ public class CacheManagerService implements CacheManager, Service { } } - protected CacheValue localGetCache(String id, Duration expire, Type cacheType) { - return localSource.get(id, cacheType); - } - - protected CompletableFuture> localGetCacheAsync(String id, Duration expire, Type cacheType) { - return localSource.getAsync(id, cacheType); - } - - protected CacheValue remoteGetCache(String id, Duration expire, Type cacheType) { - return remoteSource.get(id, cacheType); - } - - protected CompletableFuture> remoteGetCacheAsync(String id, Duration expire, Type cacheType) { - return remoteSource.getAsync(id, cacheType); - } - /** * 远程异步获取缓存数据, 过期返回null * * @param 泛型 * @param id 缓存键 + * @param expire 过期时长,Duration.ZERO为永不过期 * @param cacheType 数据类型 * @return 数据值 */ diff --git a/src/main/java/org/redkale/lock/Locked.java b/src/main/java/org/redkale/lock/Locked.java index 3d68717af..51b22601f 100644 --- a/src/main/java/org/redkale/lock/Locked.java +++ b/src/main/java/org/redkale/lock/Locked.java @@ -3,11 +3,10 @@ */ package org.redkale.lock; -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 org.redkale.service.LoadMode; @@ -15,7 +14,8 @@ import org.redkale.service.LoadMode; * //TODO 待实现 * *

标记在Service的锁接口, 方法有以下限制:
- * 2、方法必须是protected/public 3、方法不能是final/static + * 1、方法必须是protected/public
+ * 2、方法不能是final/static
* *

详情见: https://redkale.org *