Package net.solarnetwork.util
Class CachedResult<T>
java.lang.Object
net.solarnetwork.util.CachedResult<T>
- Type Parameters:
T- The type of object that is cached.
A cached object holder.
- Version:
- 1.0
- Author:
- matt
-
Constructor Summary
ConstructorsConstructorDescriptionCachedResult(T result, long created, long ttl, TimeUnit unit) Constructor.CachedResult(T result, long ttl, TimeUnit unit) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionlongGet the system time this object was created.longGet the system time this object expires at.Get the cached result object.booleanisValid()Test if this result has not expired.
-
Constructor Details
-
CachedResult
Constructor. The current time will be used for thecreatedproperty.- Parameters:
result- The result to cache.ttl- The time to live, after which the result should be considered expired.unit- The time unit for theexpiration.
-
CachedResult
Constructor.- Parameters:
result- The result to cache.created- The creation time to use for the result.ttl- The time to live, after which the result should be considered expired.unit- The time unit for theexpiration.
-
-
Method Details
-
isValid
public boolean isValid()Test if this result has not expired.- Returns:
- true if the result has not expired.
-
getCreated
public long getCreated()Get the system time this object was created.- Returns:
- The system time this object was created.
-
getExpires
public long getExpires()Get the system time this object expires at.- Returns:
- The system time this object expires at.
-
getResult
Get the cached result object.- Returns:
- The result object.
-