DEFAULT_HASH

This commit is contained in:
redkale
2023-12-24 09:18:58 +08:00
parent 240b2b226b
commit ae03bdecad
3 changed files with 9 additions and 4 deletions

View File

@@ -20,6 +20,11 @@ import org.redkale.util.ThrowSupplier;
*/
public interface CacheManager {
/**
* 默认的hash
*/
public static final String DEFAULT_HASH = "cache";
//-------------------------------------- 本地缓存 --------------------------------------
/**
* 本地获取缓存数据, 过期返回null

View File

@@ -36,11 +36,11 @@ public @interface Cached {
String key();
/**
* 缓存的hash, 默认值用当前Service类的SimpleName, 不能含有':'、'#'、'@'字符
* 缓存的hash, 不能含有':'、'#'、'@'字符
*
* @return hash
*/
String hash() default "";
String hash() default CacheManager.DEFAULT_HASH;
/**
* 本地缓存过期时长, 0表示永不过期 -1表示不作本地缓存。<br>

View File

@@ -13,7 +13,6 @@ import org.redkale.annotation.Resource;
import org.redkale.asm.AsmDepends;
import org.redkale.cache.CacheManager;
import org.redkale.convert.json.JsonConvert;
import org.redkale.net.sncp.Sncp;
import org.redkale.util.Environment;
import org.redkale.util.MultiHashKey;
import org.redkale.util.ThrowSupplier;
@@ -94,7 +93,8 @@ public class CacheAction {
void init() {
this.hash = cached.getHash().trim().isEmpty()
? Sncp.getResourceType(serviceClass).getSimpleName()
|| CacheManager.DEFAULT_HASH.equals(cached.getHash())
? CacheManager.DEFAULT_HASH
: environment.getPropertyValue(cached.getHash());
String key = environment.getPropertyValue(cached.getKey());
this.dynKey = MultiHashKey.create(paramNames, key);