数据重复进库解决方案(在redis中存放key 5秒钟,存在返回,不存在添加)

IStringCache stringCache = CacheFactory.getStringCache();
Integer time = 5;
String key = "Alert_"+eventNotificationAlertJson.getString("devIndex")+eventNotificationAlertJson.getString("eventType");
if (!stringCache.exist(key)){
stringCache.set(key,eventNotificationAlert);
stringCache.setExpireTime(key,time);
}else {
return;
}

posted @ 2025-07-25 14:32  年少轻狂请多指教  阅读(9)  评论(0)    收藏  举报