Package com.bytedesk.core.message
Class MessagePersistCache
java.lang.Object
com.bytedesk.core.message.MessagePersistCache
消息持久化缓存服务
使用Redis List结构存储消息,支持消息的推入和批量获取
- Since:
- 2024-07-16
- Author:
- jackning
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final long
private final org.springframework.data.redis.core.StringRedisTemplate
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clearCache
(String listKey) 清空指定列表的缓存获取指定列表的所有消息并清空列表从默认持久化列表获取所有消息void
init()
初始化Redis配置void
向指定列表推送消息void
pushForPersist
(String messageJSON) 向默认持久化列表推送消息
-
Field Details
-
DEFAULT_PERSIST_KEY
- See Also:
-
EXPIRE_TIME_DAYS
private static final long EXPIRE_TIME_DAYS- See Also:
-
stringRedisTemplate
private final org.springframework.data.redis.core.StringRedisTemplate stringRedisTemplate
-
-
Constructor Details
-
MessagePersistCache
public MessagePersistCache()
-
-
Method Details
-
init
@PostConstruct public void init()初始化Redis配置 -
pushForPersist
向默认持久化列表推送消息- Parameters:
messageJSON
- 消息JSON字符串
-
getListForPersist
从默认持久化列表获取所有消息- Returns:
- 消息列表,如果列表为空则返回空列表
-
push
向指定列表推送消息- Parameters:
listKey
- 列表键名messageJSON
- 消息JSON字符串
-
getList
获取指定列表的所有消息并清空列表- Parameters:
listKey
- 列表键名- Returns:
- 消息列表,如果列表为空则返回空列表
-
clearCache
清空指定列表的缓存- Parameters:
listKey
- 列表键名
-