Class TimeoutUtils
java.lang.Object
org.springframework.data.redis.core.TimeoutUtils
Helper class featuring methods for calculating Redis timeouts
- Author:
- Jennifer Hickey, Mark Paluch, Christoph Strobl
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Check if a given Duration can be represented insec
or requiresmsec
representation.static double
toDoubleSeconds
(long timeout, TimeUnit unit) Converts the given timeout to seconds with a fraction of seconds.static long
Converts the given timeout to milliseconds.static long
Converts the given timeout to seconds.static long
Converts the given timeout to seconds.
-
Constructor Details
-
TimeoutUtils
public TimeoutUtils()
-
-
Method Details
-
hasMillis
Check if a given Duration can be represented insec
or requiresmsec
representation. -
toSeconds
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:
duration
- The duration to convert- Returns:
- The converted timeout
- Since:
- 2.3
-
toSeconds
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 convertunit
- The timeout's unit- Returns:
- The converted timeout
-
toDoubleSeconds
Converts the given timeout to seconds with a fraction of seconds.- Parameters:
timeout
- The timeout to convertunit
- The timeout's unit- Returns:
- The converted timeout
- Since:
- 2.6
-
toMillis
Converts the given timeout to milliseconds.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 convertunit
- The timeout's unit- Returns:
- The converted timeout
-