redis键值对的监听,首先只能获取redis的key值,value值是获取不到的,所以将value值拼接在key值中。
其次是要知道放入redis信息的结束时间,例如未付款订单15分钟后取消订单。
该方式 在单机模式下是可行的,但是在集群中可能会出现 业务上的问题。具体不可预知。 有时间在整集群模式
下面写了一个demo来验证是否可以获取失效的key值。
redisConfig redis连接配置
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RedisConfig {
@Bean(name="redissonClient")
public RedissonClient getRedisConfig() {
Config config = new Config();
/单机
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
/集群
// SentinelServersConfig ssc = config.useSentinelServers().setMasterName(master);
// Set<String> redisSet