skip to Main Content

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

2

Answers


  1. You can do it like this:

    RedisSingle nodes = redisson.getRedisNodes(RedisNodes.SINGLE);
    Time time = nodes.getInstance().time();
    
    Login or Signup to reply.
  2. Assuming you have a RestTemplate bean in your app, you can try this:

    Long redisServerTimestamp = redisTemplate.execute(
                        (RedisCallback<Long>) conn -> conn.serverCommands().time());
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search