|
|
@@ -1,20 +1,15 @@ |
|
|
|
package cc.smtweb.framework.core.cache; |
|
|
|
|
|
|
|
import cc.smtweb.framework.core.annotation.SwCache; |
|
|
|
import cc.smtweb.framework.core.annotation.SwParam; |
|
|
|
import cc.smtweb.framework.core.cache.ISwCache; |
|
|
|
import cc.smtweb.framework.core.redis.RedisBroadcastEvent; |
|
|
|
import cc.smtweb.framework.core.redis.RedisManager; |
|
|
|
import cc.smtweb.framework.core.util.CommUtil; |
|
|
|
import cc.smtweb.framework.core.util.kryo.KryoTool; |
|
|
|
import com.github.benmanes.caffeine.cache.Caffeine; |
|
|
|
import com.github.benmanes.caffeine.cache.LoadingCache; |
|
|
|
import com.github.benmanes.caffeine.cache.RemovalCause; |
|
|
|
import com.github.benmanes.caffeine.cache.Scheduler; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.checkerframework.checker.nullness.qual.NonNull; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import java.io.Serializable; |
|
|
|
import java.util.*; |
|
|
@@ -30,14 +25,12 @@ import java.util.concurrent.TimeUnit; |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
public abstract class AbstractCache<T extends Serializable> implements ISwCache<String, T> { |
|
|
|
//树节点按parent的key |
|
|
|
public static final String KEY_PARENT_ID = "pr"; |
|
|
|
|
|
|
|
protected final static int LS_NONE = 0; |
|
|
|
protected final static int LS_LOADING = 1; |
|
|
|
protected final static int LS_LOADED = 2; |
|
|
|
|
|
|
|
private final static String split_char = "-"; |
|
|
|
private final static String SPLIT_CHAR = "-"; |
|
|
|
//唯一标识 |
|
|
|
protected String ident; |
|
|
|
//展示名称 |
|
|
@@ -285,7 +278,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< |
|
|
|
//本地调用,删除一个对象时,更新列表缓存 |
|
|
|
private void doRemoveList(String regionKey, String key, T value) { |
|
|
|
if (StringUtils.isEmpty(key)) return; |
|
|
|
Set<T> list = mapListLocal.get(regionKey + split_char + key); |
|
|
|
Set<T> list = mapListLocal.get(regionKey + SPLIT_CHAR + key); |
|
|
|
if (list == null) { |
|
|
|
return; |
|
|
|
} |
|
|
@@ -304,7 +297,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< |
|
|
|
//本地调用,更新列表缓存 |
|
|
|
private void doUpdateList(String regionKey, String key, T value) { |
|
|
|
if (StringUtils.isEmpty(key)) return; |
|
|
|
Set<T> list = mapListLocal.computeIfAbsent(regionKey + split_char + key, k -> new LinkedHashSet<>()); |
|
|
|
Set<T> list = mapListLocal.computeIfAbsent(regionKey + SPLIT_CHAR + key, k -> new LinkedHashSet<>()); |
|
|
|
list.add(value); |
|
|
|
} |
|
|
|
|
|
|
@@ -368,7 +361,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< |
|
|
|
} |
|
|
|
|
|
|
|
public final Set<T> getListByKey(String rk, String key) { |
|
|
|
return mapListLocal.get(rk + split_char + key); |
|
|
|
return mapListLocal.get(rk + SPLIT_CHAR + key); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|