Class ExpirationCache<K,​V>

    • Constructor Detail

      • ExpirationCache

        public ExpirationCache​(int maxSize,
                               long defaultExpirationTime)
        Construct a new expiration cache.
        Parameters:
        maxSize - the maximum size.
        defaultExpirationTime - the default expiration time in milliseconds.
    • Method Detail

      • setDefaultExpirationTime

        public void setDefaultExpirationTime​(long defaultExpirationTime)
        Set the default expiration time in milliseconds.
        Parameters:
        defaultExpirationTime - the default expiration time.
      • put

        public V put​(K key,
                     V value)
        Description copied from interface: Cache
        Put a value in the cache.
        Specified by:
        put in interface Cache<K,​V>
        Specified by:
        put in interface Map<K,​V>
        Parameters:
        key - the key of the value.
        value - the value.
        Returns:
        the previous value or null.
      • put

        public V put​(K key,
                     V value,
                     long expirationTime)
        Put a value in the cache with the specified expiration time in milliseconds.
        Parameters:
        key - the key of the value.
        value - the value.
        expirationTime - the expiration time in milliseconds.
        Returns:
        the previous value or null.
      • lookup

        public V lookup​(K key)
        Description copied from interface: Cache
        Returns the value of the specified key, or null.
        Specified by:
        lookup in interface Cache<K,​V>
        Parameters:
        key - the key.
        Returns:
        the value found in the cache, or null.
      • remove

        public V remove​(Object key)
        Remove a entry with the given key from the cache.
        Specified by:
        remove in interface Map<K,​V>
        Parameters:
        key - the key of the value to remove.
        Returns:
        the remove value, or null.
      • getMaxCacheSize

        public int getMaxCacheSize()
        Description copied from interface: Cache
        Return the maximum cache Size.
        Specified by:
        getMaxCacheSize in interface Cache<K,​V>
        Returns:
        the maximum cache size.
      • setMaxCacheSize

        public void setMaxCacheSize​(int maxCacheSize)
        Description copied from interface: Cache
        Set the maximum cache size.
        Specified by:
        setMaxCacheSize in interface Cache<K,​V>
        Parameters:
        maxCacheSize - the new maximum cache size.
      • size

        public int size()
        Specified by:
        size in interface Map<K,​V>
      • putAll

        public void putAll​(Map<? extends K,​? extends V> m)
        Specified by:
        putAll in interface Map<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface Map<K,​V>