|
|
@ -310,24 +310,6 @@ public class RedisService |
|
|
return redisTemplate.opsForHash().increment(key, hashKey,delta); |
|
|
return redisTemplate.opsForHash().increment(key, hashKey,delta); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 加锁 |
|
|
|
|
|
**/ |
|
|
|
|
|
public Boolean lock(String key,String value,Long duration){ |
|
|
|
|
|
Boolean lockStatus = this.redisTemplate.opsForValue().setIfAbsent(key,value, Duration.ofSeconds(duration)); |
|
|
|
|
|
return lockStatus; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 释放锁 |
|
|
|
|
|
**/ |
|
|
|
|
|
public Long releaseLock(String key,String value){ |
|
|
|
|
|
String luaScript = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end"; |
|
|
|
|
|
RedisScript<Long> redisScript = new DefaultRedisScript<>(luaScript,Long.class); |
|
|
|
|
|
Long releaseStatus = (Long)this.redisTemplate.execute(redisScript, Collections.singletonList(key),value); |
|
|
|
|
|
return releaseStatus; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* pv统计 |
|
|
* pv统计 |
|
|
* @param today 统计的日期 |
|
|
* @param today 统计的日期 |
|
|
|