java.lang.Object | |
↳ | com.kinvey.java.cache.InMemoryLRUCache<T, V> |
This is a very simple implementation of a Least-Recently-Used In-Memory Cache.
It utilizes a LinkedHashMaps removeEldestEntry() override to remove older elements.
This interface is thread-safe. All accessors (get/put) are synchronized on the cache object itself.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
InMemoryLRUCache()
Use the default cache size and load factor for a new in-memory cache
| |||||||||||
InMemoryLRUCache(int cacheSize)
Use a custom cache size but the default load factor for a new in-memory cache.
| |||||||||||
InMemoryLRUCache(int cacheSize, float loadFactor)
Use a custom cache size and a custom load factor for a new in-memory cache.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
V |
get(T key)
Pull a value from the cache with the associated key.
| ||||||||||
void |
put(T key, V value)
Put a Value in the LRUCache with the associated Key
This method is threadsafe through java's synchronization.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Use the default cache size and load factor for a new in-memory cache
Use a custom cache size but the default load factor for a new in-memory cache.
Use a custom cache size and a custom load factor for a new in-memory cache.
Pull a value from the cache with the associated key. This method is threadsafe through java's synchronization.
key | - the Key of the value to retrieve |
---|
Put a Value in the LRUCache with the associated Key This method is threadsafe through java's synchronization.
key | - the Key of the Value to store |
---|---|
value | - the Value to store |