Interface IDataCacheEntry


  • public interface IDataCacheEntry

    A data cache entry represents an entity that is cached by the Data Cache API. It mainly consists of a name (an identifier) and value, which is cached in-memory until its scope is destroyed or the entry, its group or the whole cache container is invalidated.

    A lifetime or a daily invalidation time can be set for each data cache entry (same principle as in Data Cache Groups). When the lifetime or the daily invalidation time is reached, then the entry is invalidated (i.e. deleted). Note that the invalidation is it is not guaranteed to be made precisely at the chosen moment as this is done by a low-priority background job

    Note, that entries may be deleted when the available free memory is critical

    Since:
    14.08.2008
    API:
    This is a public API.
    • Method Detail

      • getIdentifier

        String getIdentifier()
        Returns the identifier of this cache entry. The identifier must be uniques within the data cache group it resides in.
        Returns:
        the identifier
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getLastHit

        Date getLastHit()
        Returns the date and time of the last cache hit, i.e. when this cache value was requested most recently
        Returns:
        the date and time of the last cache hit or null if entry was never read
        See Also:
        getValue()
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getLoadDate

        Date getLoadDate()
        Returns the load date of this data cache entry. The load date is the date and time of the last setting of the entry's value or (if never set after creation) the creation date and time. If a lifetime is set, then the entry is invalidated after load date + lifetime.
        Returns:
        the load date of this cache entry or null if entry was never initialized with a value
        See Also:
        getLifetime()
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getLifetime

        int getLifetime()
        Returns the full lifetime of this cache entry in seconds. To compute the point in time when the entry will get invalid, you have to do something like new Date(getLoadDate().getTime() + lifetime)
        Returns:
        the lifetime in seconds; -1 for infinite lifetime
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • setLifetime

        void setLifetime​(int lifetime)
        Sets the lifetime of this cache entry. If set, the entry is invalidated when the lifetime is elapsed after the creation of the entry. Setting the value of the entry after its creation re-starts this countdown for invalidation.

        Note that the invalidation is performed asynchronously by a background job (see the system property DataCache.InvalidationJob.Interval for the interval of execution) and therefore the invalidation does not take place precisely after end of the lifetime but just during the first execution of that job thereafter

        Parameters:
        lifetime - the lifetime in seconds; -1 for infinite lifetime
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • getValue

        Object getValue()
        Returns the value of this cache entry and sets the last hit date
        Returns:
        the value
        See Also:
        getLastHit()
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • setValue

        void setValue​(Object value)
        Sets the value of this data cache entry. This initiates that the entry is considered as new loaded. So, the lifetime of the entry is re-set to the starting amount.
        Parameters:
        value - the value to set
        See Also:
        getLoadDate()
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • setInvalidationTime

        void setInvalidationTime​(String time)
        Sets the daily invalidation time of this cache entry. If set, the entry is invalidated once daily after that time is reached.

        Note that the invalidation is executed asynchronously by a background job (see the system property DataCache.InvalidationJob.Interval for the interval of execution) and therefore the invalidation does not take place precisely at the invalidation time but just during the first execution of that job after the invalidation time

        Parameters:
        time - the time to set in hh:mm format; null to unset
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • getInvalidationTime

        String getInvalidationTime()
        Returns the daily invalidation time of this cache entry.
        Returns:
        the lifetime in seconds; null for no invalidation time
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.