import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.RedisScript;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
/**
* @Description
* @Author
* @Date 2020/9/18 11:22
*/
@Slf4j
@Component
public class RedisLock {
private static final Long SUCCESS = 1L;
@Autowired
private RedisTemplate redisTemplate;
//上锁脚本
private static final String LOCK_LUA = "if redis.call('setnx', KEYS[1], ARGV[1]) == 1 then redis.call('expire', KEYS[1], ARGV[2]) return 'true' else return 'false' end";
//解锁脚本
private static final String UNLOCK_LUA =
redis锁操作
最新推荐文章于 2024-04-23 13:48:40 发布