silentfish
silentfish

Reputation: 11

how to get the current time by use redisson client

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

Answers (2)

Andrei
Andrei

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

Nikita Koksharov
Nikita Koksharov

Reputation: 10793

You can do it like this:

RedisSingle nodes = redisson.getRedisNodes(RedisNodes.SINGLE);
Time time = nodes.getInstance().time();

Upvotes: 0

Related Questions