1

if i have several servers, maybe servers's current system time are different. how can i all use redisson to get current time?

I've read the RedissonClient api, but I haven't found the way to get this yet

silentfish
  • 11
  • 1

2 Answers2

1

Assuming you have a RestTemplate bean in your app, you can try this:

Long redisServerTimestamp = redisTemplate.execute(
                    (RedisCallback<Long>) conn -> conn.serverCommands().time());
Andrei
  • 11
  • 1
0

You can do it like this:

RedisSingle nodes = redisson.getRedisNodes(RedisNodes.SINGLE);
Time time = nodes.getInstance().time();
Nikita Koksharov
  • 10,283
  • 1
  • 62
  • 71