RedisScript redisScript =
RedisScript.of("local tmp = redis.call('get', KEYS[1])\n" +
"if tmp == false then\n" +
" redis.call('set',KEYS[1],KEYS[2])\n" +
" return 1\n" +
"end\n" +
"return 0\n",
Long.class);
List<String> list = new ArrayList<>();
list.add("test-lock");
list.add("test-lock");
Long execute = (Long) redisTemplate.execute(redisScript, list, "60");
System.err.println("执行结果:" + execute);
网友评论