diff --git a/redisson/src/main/java/org/redisson/client/RedisConnection.java b/redisson/src/main/java/org/redisson/client/RedisConnection.java index 65c2ed36a..2fd5751bb 100644 --- a/redisson/src/main/java/org/redisson/client/RedisConnection.java +++ b/redisson/src/main/java/org/redisson/client/RedisConnection.java @@ -62,7 +62,7 @@ public class RedisConnection implements RedisCommands { this.connectionPromise = connectionPromise; updateChannel(channel); - lastUsageTime = System.currentTimeMillis(); + lastUsageTime = System.nanoTime(); } protected RedisConnection(RedisClient redisClient) { diff --git a/redisson/src/main/java/org/redisson/connection/ClientConnectionsEntry.java b/redisson/src/main/java/org/redisson/connection/ClientConnectionsEntry.java index fd8147291..8f73953cb 100644 --- a/redisson/src/main/java/org/redisson/connection/ClientConnectionsEntry.java +++ b/redisson/src/main/java/org/redisson/connection/ClientConnectionsEntry.java @@ -169,7 +169,7 @@ public class ClientConnectionsEntry { return; } - connection.setLastUsageTime(System.currentTimeMillis()); + connection.setLastUsageTime(System.nanoTime()); freeConnections.add(connection); } @@ -247,7 +247,7 @@ public class ClientConnectionsEntry { return; } - connection.setLastUsageTime(System.currentTimeMillis()); + connection.setLastUsageTime(System.nanoTime()); freeSubscribeConnections.add(connection); } diff --git a/redisson/src/main/java/org/redisson/connection/IdleConnectionWatcher.java b/redisson/src/main/java/org/redisson/connection/IdleConnectionWatcher.java index b612677d5..ce4b2fdc3 100644 --- a/redisson/src/main/java/org/redisson/connection/IdleConnectionWatcher.java +++ b/redisson/src/main/java/org/redisson/connection/IdleConnectionWatcher.java @@ -63,14 +63,14 @@ public class IdleConnectionWatcher { @Override public void run() { - long currTime = System.currentTimeMillis(); + long currTime = System.nanoTime(); for (Entry entry : entries) { if (!validateAmount(entry)) { continue; } for (RedisConnection c : entry.connections) { - long timeInPool = currTime - c.getLastUsageTime(); + long timeInPool = TimeUnit.NANOSECONDS.toMillis(currTime - c.getLastUsageTime()); if (timeInPool > config.getIdleConnectionTimeout() && validateAmount(entry) && entry.deleteHandler.apply(c)) {