@Override public long nextTimestamp() { long time = System.currentTimeMillis() << 12; return redisson.getScript(LongCodec.INSTANCE).eval(RScript.Mode.READ_WRITE, "local currentTime = redis.call('get', KEYS[1]);" + "if currentTime == false then " + "redis.call('set', KEYS[1], ARGV[1]); " + "return ARGV[1]; " + "end;" + "local nextValue = math.max(tonumber(ARGV[1]), tonumber(currentTime) + 1); " + "redis.call('set', KEYS[1], nextValue); " + "return nextValue;", RScript.ReturnType.INTEGER, Arrays.<Object>asList("redisson-hibernate-timestamp"), time); }
@Override public long nextTimestamp() { long time = System.currentTimeMillis() << 12; return redisson.getScript(LongCodec.INSTANCE).eval(RScript.Mode.READ_WRITE, "local currentTime = redis.call('get', KEYS[1]);" + "if currentTime == false then " + "redis.call('set', KEYS[1], ARGV[1]); " + "return ARGV[1]; " + "end;" + "local nextValue = math.max(tonumber(ARGV[1]), tonumber(currentTime) + 1); " + "redis.call('set', KEYS[1], nextValue); " + "return nextValue;", RScript.ReturnType.INTEGER, Arrays.<Object>asList("redisson-hibernate-timestamp"), time); }
@Override public long nextTimestamp() { long time = System.currentTimeMillis() << 12; return redisson.getScript(LongCodec.INSTANCE).eval(RScript.Mode.READ_WRITE, "local currentTime = redis.call('get', KEYS[1]);" + "if currentTime == false then " + "redis.call('set', KEYS[1], ARGV[1]); " + "return ARGV[1]; " + "end;" + "local nextValue = math.max(tonumber(ARGV[1]), tonumber(currentTime) + 1); " + "redis.call('set', KEYS[1], nextValue); " + "return nextValue;", RScript.ReturnType.INTEGER, Arrays.<Object>asList("redisson-hibernate-timestamp"), time); }
@Override public long nextTimestamp() { long time = System.currentTimeMillis() << 12; return redisson.getScript(LongCodec.INSTANCE).eval(RScript.Mode.READ_WRITE, "local currentTime = redis.call('get', KEYS[1]);" + "if currentTime == false then " + "redis.call('set', KEYS[1], ARGV[1]); " + "return ARGV[1]; " + "end;" + "local nextValue = math.max(tonumber(ARGV[1]), tonumber(currentTime) + 1); " + "redis.call('set', KEYS[1], nextValue); " + "return nextValue;", RScript.ReturnType.INTEGER, Arrays.<Object>asList("redisson-hibernate-timestamp"), time); }
public long nextTimestamp(final List<Object> keys) { return redisson.getScript().eval(RScript.Mode.READ_WRITE, "redis.call('setnx', KEYS[1], ARGV[1]); " + "return redis.call('incr', KEYS[1]);", RScript.ReturnType.INTEGER, keys, System.currentTimeMillis()); }
public long nextTimestamp(final List<Object> keys) { return redisson.getScript().eval(RScript.Mode.READ_WRITE, "redis.call('setnx', KEYS[1], ARGV[1]); " + "return redis.call('incr', KEYS[1]);", RScript.ReturnType.INTEGER, keys, System.currentTimeMillis()); }
public long nextTimestamp(final List<Object> keys) { return redisson.getScript().eval(RScript.Mode.READ_WRITE, "redis.call('setnx', KEYS[1], ARGV[1]); " + "return redis.call('incr', KEYS[1]);", RScript.ReturnType.INTEGER, keys, System.currentTimeMillis()); }
@Override public boolean unlock(String key, String requestId) { String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end"; return redissonClient.getScript().eval(Mode.READ_WRITE, script, ReturnType.BOOLEAN, ArrayUtils.newArrayList(key), requestId); }
/** * 获取当前时间 * * @return time */ protected long time() { return BeanStore.getBean(RedissonClient.class).getScript().eval(Mode.READ_ONLY, "return redis.call('TIME')[1]*1000", ReturnType.INTEGER); }