public class DefaultCachePolicy extends java.lang.Object implements ConnectionCachePolicy
ConnectionCachePolicy, reproducing the legacy
AbstractReadWriteSplittingPlugin.getKeepAliveTimeout behavior: pooled connections defer
their lifetime to the pool (deadline 0); non-pooled connections use
cachedReaderKeepAliveTimeoutMs (default 0 = keep reusing indefinitely).
The clock is injectable via NanoTimeSource so deadline computation is unit-testable
without real waits.
| Constructor and Description |
|---|
DefaultCachePolicy(long keepAliveMs,
NanoTimeSource timeSource) |
DefaultCachePolicy(java.util.Properties properties) |
| Modifier and Type | Method and Description |
|---|---|
long |
keepAliveDeadlineNanos(boolean fromPool)
Returns the
System.nanoTime()-based deadline after which a cached connection may be
released, or 0 to keep it (pool-managed, or reuse indefinitely). |
public DefaultCachePolicy(java.util.Properties properties)
public DefaultCachePolicy(long keepAliveMs,
NanoTimeSource timeSource)
public long keepAliveDeadlineNanos(boolean fromPool)
ConnectionCachePolicySystem.nanoTime()-based deadline after which a cached connection may be
released, or 0 to keep it (pool-managed, or reuse indefinitely).keepAliveDeadlineNanos in interface ConnectionCachePolicyfromPool - whether the connection came from an internal connection pool0