Redis实现分布式锁,非lua脚本
Redis实现分布式锁,非lua脚本
初始化Spring StringRedisTemplate
LettuceConnectionFactory factory = new LettuceConnectionFactory();
factory.setHostName("localhost");
factory.setPort(6379);
factory.afterPropertiesSet();
StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
stringRedisTemplate.setConnectionFactory(factory);
stringRedisTemplate.afterPropertiesSet();
//清空上次测试数据
stringRedisTemplate.delete("lock:
共有 0 条评论