Class Cache.SimpleLruMemCache

  • All Implemented Interfaces:
    Cache
    Enclosing interface:
    Cache

    public static final class Cache.SimpleLruMemCache
    extends Object
    implements Cache
    Simple In-Memory LRU cache. Per default has CACHE_SIZE size for mask & unmask cache.

    See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)

    • Constructor Detail

      • SimpleLruMemCache

        public SimpleLruMemCache()
      • SimpleLruMemCache

        public SimpleLruMemCache​(int size)
    • Method Detail

      • cache

        public void cache​(byte[] originalId,
                          String encoded)
        Description copied from interface: Cache
        Puts a new id and it's encoded form in the cache.
        Specified by:
        cache in interface Cache
        Parameters:
        originalId - the id
        encoded - the masked/encoded form of originalId
      • getEncoded

        public String getEncoded​(byte[] originalId)
        Description copied from interface: Cache
        Retrieve the encoded form of given original id. This is used when encoding/masking.
        Specified by:
        getEncoded in interface Cache
        Parameters:
        originalId - to get cache content for
        Returns:
        encoded version of originalId if found, null otherwise
      • getBytes

        public byte[] getBytes​(String encoded)
        Description copied from interface: Cache
        Retrieve the originalId form of given encoded id. This is used when decoding/unmasking.
        Specified by:
        getBytes in interface Cache
        Parameters:
        encoded - to get cache content for
        Returns:
        original id of encoded id if found, null otherwise
      • clear

        public void clear()
        Description copied from interface: Cache
        Clears internal cache.
        Specified by:
        clear in interface Cache