org.springframework.data.redis.core
Class TimeoutUtils

java.lang.Object
  extended by org.springframework.data.redis.core.TimeoutUtils

public abstract class TimeoutUtils
extends Object

Helper class featuring methods for calculating Redis timeouts


Constructor Summary
TimeoutUtils()
           
 
Method Summary
static long toSeconds(long timeout, TimeUnit unit)
          Converts the given timeout to seconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeoutUtils

public TimeoutUtils()
Method Detail

toSeconds

public static long toSeconds(long timeout,
                             TimeUnit unit)
Converts the given timeout to seconds.

Since a 0 timeout blocks some Redis ops indefinitely, this method will return 1 if the original value is greater than 0 but is truncated to 0 on conversion.

Parameters:
timeout - The timeout to convert
unit - The timeout's unit
Returns:
The converted timeout