Class TouchedExpiryPolicy

  • All Implemented Interfaces:
    java.io.Serializable, ExpiryPolicy

    public final class TouchedExpiryPolicy
    extends java.lang.Object
    implements ExpiryPolicy, java.io.Serializable
    An ExpiryPolicy that defines the expiry Duration of a Cache Entry based on when it was last touched. A touch includes creation, update or access.
    Since:
    1.0
    See Also:
    ExpiryPolicy, Serialized Form
    • Field Detail

      • serialVersionUID

        public static final long serialVersionUID
        The serialVersionUID required for Serializable.
        See Also:
        Constant Field Values
      • expiryDuration

        private Duration expiryDuration
        The Duration a Cache Entry should be available before it expires.
    • Constructor Detail

      • TouchedExpiryPolicy

        public TouchedExpiryPolicy​(Duration expiryDuration)
        Parameters:
        expiryDuration - the Duration a Cache Entry should exist be before it expires after being modified
    • Method Detail

      • getExpiryForCreation

        public Duration getExpiryForCreation()
        Gets the Duration before a newly created Cache.Entry is considered expired.

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

        Should an exception occur while determining the Duration, an implementation specific default Duration will be used.

        Specified by:
        getExpiryForCreation in interface ExpiryPolicy
        Returns:
        the new Duration before a created entry expires
      • getExpiryForAccess

        public Duration getExpiryForAccess()
        Gets the Duration before an accessed Cache.Entry is considered expired.

        This method is called by a caching implementation after a Cache.Entry is accessed to determine the Duration before an entry expires. If a Duration.ZERO is returned a Cache.Entry will be considered immediately expired. Returning null will result in no change to the previously understood expiry Duration.

        Should an exception occur while determining the Duration, an implementation specific default Duration will be used.

        Specified by:
        getExpiryForAccess in interface ExpiryPolicy
        Returns:
        the new Duration before an accessed entry expires
      • getExpiryForUpdate

        public Duration getExpiryForUpdate()
        Gets the Duration before an updated Cache.Entry is considered expired.

        This method is called by the caching implementation after a Cache.Entry is updated to determine the Duration before the updated entry expires. If a Duration.ZERO is returned a Cache.Entry is considered immediately expired. Returning null will result in no change to the previously understood expiry Duration.

        Should an exception occur while determining the Duration, an implementation specific default Duration will be used.

        Specified by:
        getExpiryForUpdate in interface ExpiryPolicy
        Returns:
        the new Duration before an updated entry expires
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object