Package at.favre.lib.idmask
Class Cache.SimpleLruMemCache
- java.lang.Object
-
- at.favre.lib.idmask.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 hasCACHE_SIZE
size for mask & unmask cache.See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface at.favre.lib.idmask.Cache
Cache.SimpleLruMemCache
-
-
Constructor Summary
Constructors Constructor Description SimpleLruMemCache()
SimpleLruMemCache(int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cache(byte[] originalId, String encoded)
Puts a new id and it's encoded form in the cache.void
clear()
Clears internal cache.byte[]
getBytes(String encoded)
Retrieve the originalId form of given encoded id.String
getEncoded(byte[] originalId)
Retrieve the encoded form of given original id.
-
-
-
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.
-
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 interfaceCache
- 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.
-
-