Interface ICacheEntry

All Superinterfaces:
Serializable
All Known Implementing Classes:
BoxCacheEntry

public interface ICacheEntry extends Serializable
Interface that defines a cache entry contract for BoxLang cache implementations and its object storages (@see IObjectStore) This interface serves as the primary communication mechanism between BoxCaches and their underlying object pools. Each cache entry represents a cached object with associated metadata including creation time, access patterns, expiration information, and custom metadata. Cache entries maintain state information such as hit counts, timestamps, and timeout configurations to support various caching strategies including LRU, time-based expiration, and access-based eviction policies. Implementations of this interface should be thread-safe as cache entries may be accessed concurrently by multiple threads in a multi-threaded environment.
Since:
1.0.0
  • Method Details

    • cacheName

      Key cacheName()
      The name of the cache this entry belongs to
      Returns:
      The cache name
    • hits

      long hits()
      The number of hits this cache entry has had
      Returns:
      The number of hits
    • timeout

      long timeout()
      The timeout of this cache entry in seconds since creation.
      Returns:
      The timeout in seconds
    • lastAccessTimeout

      long lastAccessTimeout()
      The last access timeout of this cache entry in seconds
      Returns:
      The last access timeout in seconds
    • created

      Instant created()
      When this cache entry was created
      Returns:
      The creation timestamp
    • lastAccessed

      Instant lastAccessed()
      When this cache entry was last accessed
      Returns:
      The last access timestamp
    • isEternal

      boolean isEternal()
      Is this an eternal object
      Returns:
      True if the object is eternal, false otherwise
    • key

      Key key()
      The key associated with this entry
      Returns:
      The key
    • value

      Attempt<Object> value()
      The value associated with this entry, if any.
      Returns:
      The attempt that represents the value from the cache
    • rawValue

      Object rawValue()
      The raw value of the cache entry
      Returns:
      The raw value or null
    • metadata

      IStruct metadata()
      An entry can store custom information to the entry
      Returns:
      A struct with the metadata
    • touchLastAccessed

      ICacheEntry touchLastAccessed()
      Resets the last accessed date
    • resetCreated

      ICacheEntry resetCreated()
      Reset the created date
    • incrementHits

      ICacheEntry incrementHits()
      Increment the hits
    • toStruct

      IStruct toStruct()
      Get the state of the entry as a struct
    • isExpired

      default boolean isExpired()
      Verifies if this cache entry has expired
    • sizeInBytes

      default long sizeInBytes()
      If available, it will get the size of the cache entry in bytes. This is not required, but if the cache provider can provide this information, it will be used to calculate the size of the cache.