javax.cache
Class ExpiryPolicy.Modified<K,V>

java.lang.Object
  extended by javax.cache.ExpiryPolicy.Modified<K,V>
Type Parameters:
K - the type of cache keys
V - the type of cache values
All Implemented Interfaces:
ExpiryPolicy<K,V>
Enclosing interface:
ExpiryPolicy<K,V>

public static final class ExpiryPolicy.Modified<K,V>
extends Object
implements ExpiryPolicy<K,V>

A ExpiryPolicy that defines the expiry Configuration.Duration of a Cache Entry based on the last time it was modified.


Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.cache.ExpiryPolicy
ExpiryPolicy.Accessed<K,V>, ExpiryPolicy.Default<K,V>, ExpiryPolicy.Modified<K,V>
 
Constructor Summary
ExpiryPolicy.Modified(Configuration.Duration expiryDuration)
          Constructs an ExpiryPolicy.Modified ExpiryPolicy.
 
Method Summary
 boolean equals(Object obj)
          
 Configuration.Duration getTTLForAccessedEntry(Cache.Entry<? extends K,? extends V> entry, Configuration.Duration duration)
          Gets the time-to-live before the accessed Cache.Entry is considered expired.
 Configuration.Duration getTTLForCreatedEntry(Cache.Entry<? extends K,? extends V> entry)
          Gets the time-to-live before the newly Cache.Entry is considered expired.
 Configuration.Duration getTTLForModifiedEntry(Cache.Entry<? extends K,? extends V> entry, Configuration.Duration duration)
          Gets the time-to-live before the modified Cache.Entry is considered expired.
 int hashCode()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpiryPolicy.Modified

public ExpiryPolicy.Modified(Configuration.Duration expiryDuration)
Constructs an ExpiryPolicy.Modified ExpiryPolicy.

Parameters:
expiryDuration - the Configuration.Duration a Cache Entry should exist be before it expires after being modified
Method Detail

getTTLForCreatedEntry

public Configuration.Duration getTTLForCreatedEntry(Cache.Entry<? extends K,? extends V> entry)
Gets the time-to-live before the newly Cache.Entry is considered expired.

This method is called after a Cache.Entry is created, but before the said entry is added to a cache, to determine the Configuration.Duration before the said entry expires. If a Configuration.Duration.ZERO is returned the Cache.Entry is considered to be already expired and will not be added to the Cache.

Specified by:
getTTLForCreatedEntry in interface ExpiryPolicy<K,V>
Parameters:
entry - the cache entry that was created
Returns:
the duration until the entry expires

getTTLForAccessedEntry

public Configuration.Duration getTTLForAccessedEntry(Cache.Entry<? extends K,? extends V> entry,
                                                     Configuration.Duration duration)
Gets the time-to-live before the accessed Cache.Entry is considered expired.

This method is called after a Cache.Entry is accessed to determine the Configuration.Duration before the said entry expires in the future. If a Configuration.Duration.ZERO is returned the Cache.Entry will be considered expired for future access.

Specified by:
getTTLForAccessedEntry in interface ExpiryPolicy<K,V>
Parameters:
entry - the cache entry that was accessed
duration - the current Configuration.Duration before the entry expires
Returns:
the duration until the entry expires

getTTLForModifiedEntry

public Configuration.Duration getTTLForModifiedEntry(Cache.Entry<? extends K,? extends V> entry,
                                                     Configuration.Duration duration)
Gets the time-to-live before the modified Cache.Entry is considered expired.

This method is called after a Cache.Entry is modified to determine the Configuration.Duration before the updated entry expires. If a Configuration.Duration.ZERO is returned the Cache.Entry is considered already expired.

Specified by:
getTTLForModifiedEntry in interface ExpiryPolicy<K,V>
Parameters:
entry - the cache entry that was modified
duration - the current Configuration.Duration before the updated entry expires
Returns:
the duration until the entry expires

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object


Copyright © 2013. All Rights Reserved.