com.rshtech.util
Interface Cached

All Known Implementing Classes:
CachedObject, SoftCachedObject

public interface Cached

Interface for cached objects to implement.

Version:
$Revision: 3127 $
Author:
$Author: kostya $

Method Summary
 void expire()
          Forcibly expire the object regardless of its internal state.
 long getCreationTime()
          Returns the time (in milliseconds) the object was created.
 long getExpirationLimit()
          Get the expiration limit (in milliseconds).
 long getLastUseTime()
          Returns the last time (in milliseconds) this object was used or accessed.
 long getUnusedExpirationLimit()
          Get the expiration limit (in milliseconds).
 boolean isExpired()
          Is the implementation expired (should it be removed from a cache or discarded)?
 boolean isExpired(long expirationVal, long unusedExpirationVal)
          Is the implementation expired (should it be removed from a cache or discarded) based on the supplied criteria?
 void renew()
          Renew an object (at least removing a forcible expiration, possibly resetting internal state).
 void setExpirationLimit(long expirationVal)
          Set the expiration limit (in milliseconds).
 void setLastUseTime()
          Notify the implementation that it should mark the last use time using the current time.
 void setLastUseTime(long lastUseTime)
          Set the last use time for the implementation using the specified value (in milliseconds).
 void setUnusedExpirationLimit(long expirationVal)
          Set the unused expiration limit (in milliseconds).
 

Method Detail

getCreationTime

long getCreationTime()
Returns the time (in milliseconds) the object was created. The created time usually reflects when the object was cached, not when it was necessarily created (although the two can be the same).

Returns:
the creation time in milliseconds

getLastUseTime

long getLastUseTime()
Returns the last time (in milliseconds) this object was used or accessed. It is the job of the implementation to set this value or the enclosing code or data structure must do it using setLastUseTime().

Returns:
the last time (in milliseconds) this object was used.

setLastUseTime

void setLastUseTime()
Notify the implementation that it should mark the last use time using the current time.


setLastUseTime

void setLastUseTime(long lastUseTime)
Set the last use time for the implementation using the specified value (in milliseconds).

Parameters:
lastUseTime - the milliseconds value to use.

isExpired

boolean isExpired()
Is the implementation expired (should it be removed from a cache or discarded)?

Returns:
true of the internal state of the implementation shows it to be expired or stale, false otherwise.

isExpired

boolean isExpired(long expirationVal,
                  long unusedExpirationVal)
Is the implementation expired (should it be removed from a cache or discarded) based on the supplied criteria?

Parameters:
expirationVal - the amount of milliseconds that can pass since the creation time before the implementation is considered expired. A value of -1 is considered a "disabled" value and such values should then be ignored (that is the implementation should never expire on the creation time).
unusedExpirationVal - the amount of milliseconds that can pass since the last use time before the implementation is considered expired. A value of -1 is considered a "disabled" value and such values should then be ignored (that is the implementation should never expire on the last use time).
Returns:
true of the internal state of the implementation shows it to be expired or stale, false otherwise.

expire

void expire()
Forcibly expire the object regardless of its internal state.


renew

void renew()
Renew an object (at least removing a forcible expiration, possibly resetting internal state).


getExpirationLimit

long getExpirationLimit()
Get the expiration limit (in milliseconds). The expiration limit is the amount of milliseconds that can pass since the creation time before the implementation is considered expired. A value of -1 is considered a "disabled" value and such values should then be ignored (that is the implementation should never expire on the creation time).


setExpirationLimit

void setExpirationLimit(long expirationVal)
Set the expiration limit (in milliseconds).

Parameters:
expirationVal - the amount of milliseconds that can pass since the creation time before the implementation is considered expired. A value of -1 is considered a "disabled" value and such values should then be ignored (that is the implementation should never expire on the creation time).

getUnusedExpirationLimit

long getUnusedExpirationLimit()
Get the expiration limit (in milliseconds). The expiration limit is the amount of milliseconds that can pass since the last use time before the implementation is considered expired. A value of -1 is considered a "disabled" value and such values should then be ignored (that is the implementation should never expire on the last use time).


setUnusedExpirationLimit

void setUnusedExpirationLimit(long expirationVal)
Set the unused expiration limit (in milliseconds).

Parameters:
expirationVal - the amount of milliseconds that can pass since the last use time before the implementation is considered expired. A value of -1 is considered a "disabled" value and such values should then be ignored (that is the implementation should never expire on the last use time).