Class CacheItem


  • public class CacheItem
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.time.LocalDateTime expiresAt  
      private java.time.Duration ttl  
      private boolean value  
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheItem()  
      CacheItem​(boolean value, java.time.Duration ttl)
      Constructs a CacheItem with a specified value and time-to-live (ttl).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean getValue()
      Retrieves the cached value.
      boolean isExpired()
      Checks whether the cache item has expired based on the current time and its ttl.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • value

        private boolean value
      • expiresAt

        private java.time.LocalDateTime expiresAt
      • ttl

        private java.time.Duration ttl
    • Constructor Detail

      • CacheItem

        CacheItem()
      • CacheItem

        public CacheItem​(boolean value,
                         java.time.Duration ttl)
        Constructs a CacheItem with a specified value and time-to-live (ttl).
        Parameters:
        value - The boolean value to be cached.
        ttl - The duration for which this item should remain in the cache.
    • Method Detail

      • isExpired

        public boolean isExpired()
        Checks whether the cache item has expired based on the current time and its ttl.
        Returns:
        True if the cache item is expired, false otherwise.
      • getValue

        public boolean getValue()
        Retrieves the cached value.
        Returns:
        The boolean value stored in this cache item.