Class ConcurrentLRUCache

  • All Implemented Interfaces:

    
    public final class ConcurrentLRUCache<K extends Object, V extends Object>
    
                        

    A very simple yet fast LRU cache with TTL support

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Long ttl
      private final Integer size
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Long getTtl() Expires in seconds
      final Integer getSize()
      final V get(K key)
      final V put(K key, V value)
      final V remove()
      final V remove(K key)
      final V computeIfAbsent(K key, Function1<K, V> mappingFunction)
      final Unit clear()
      • Methods inherited from class java.lang.Object

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

      • ConcurrentLRUCache

        ConcurrentLRUCache(Integer capacity)
      • ConcurrentLRUCache

        ConcurrentLRUCache(Duration ttl, Integer capacity)
        Construct a least recently used cache
        Parameters:
        ttl - Time to live for items
        capacity - The max size of the cache
      • ConcurrentLRUCache

        ConcurrentLRUCache(Long ttl, Integer capacity)
        Construct a least recently used cache
        Parameters:
        ttl - Time to live for items, in seconds
        capacity - The max size of the cache