248 Star 1.8K Fork 606

GVP京东零售 / hotkey

 / 详情

Redis数据推送到JVM后,如果Redis数据发生变化,会同步刷新JVM中的数据吗

Backlog
Task
Opened this issue  
2020-09-07 11:20

请问Redis数据推送到JVM后,如果Redis数据发生变化,会同步刷新到JVM中吗

Comments (4)

田野里的枫 created任务
Expand operation logs

与redis无关,不依赖redis。
如果缓存的值有变化,可以调用remove(key)方法删除整个集群的该key缓存

可以考虑,通过netty以及etcd通知,发布缓存的值发生了改变这个事件

public static ConcurrentHashMap<String, AtomicInteger> ChangeComing = new ConcurrentHashMap<>();

public String get(String key) {
Object object = JdHotKeyStore.getValue(key);
//如果已经缓存过了
if (object != null)
{
AtomicInteger ref = ChangeComing.get(key);
if (ref != null && ref.compareAndSet(0, 1))
{
String value = getFromRedis(key);
JdHotKeyStore.smartSet(key, value);
ChangeComing.remove(key);
return value;
} else
{
System.out.println("is hot key");
return object.toString();
}
} else
{
String value = getFromRedis(key);
JdHotKeyStore.smartSet(key, value);
return value;
}
} 粗体

不会,框架与redis没有关系

可以通过调用api,remove(String key)方法,删除整个集群内所有缓存的该key

Sign in to comment

Status
Assignees
Projects
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
Duration (hours)
Confirm
参与者(3)
303698 tianyalei 1578919857
Java
1
https://gitee.com/jd-platform-opensource/hotkey.git
git@gitee.com:jd-platform-opensource/hotkey.git
jd-platform-opensource
hotkey
hotkey

Search

181749 a2d7925e 1850385 181749 9f8568a7 1850385