Reputation: 11
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
Upvotes: 1
Views: 612
Reputation: 11
Assuming you have a RestTemplate bean in your app, you can try this:
Long redisServerTimestamp = redisTemplate.execute(
(RedisCallback<Long>) conn -> conn.serverCommands().time());
Upvotes: 1
Reputation: 10793
You can do it like this:
RedisSingle nodes = redisson.getRedisNodes(RedisNodes.SINGLE);
Time time = nodes.getInstance().time();
Upvotes: 0