class LinearProbingCache : InMemoryCache
A thread-safe InMemoryCache with a custom HashTable implementation based on Linear Probing.
class TombStoneMarker : Cacheable
A marker which replaces deleted objects. If the space is marked as null after deletion, then it leaves other objects with same hash codes unreachable. Search continues if the current cell has a TombStoneMarker. |
LinearProbingCache(size: Int, persistentStores: List<CacheStore> = emptyList(), replacementPolicy: CacheReplacementPolicy = FifoCacheReplacementPolicy(size))
A thread-safe InMemoryCache with a custom HashTable implementation based on Linear Probing. |
val lock: <ERROR CLASS>
A read write lock for thread safety. |
|
open val persistentStores: List<CacheStore>
List of persistent stores backing cache. |
|
open val replacementPolicy: CacheReplacementPolicy
Cache replacement policy to create space when cache is full. |
|
open val size: Int
Size of the cache |
fun <T : Cacheable> addObject(obj: T): Boolean
Adds a Cacheable object to the cache. The cache key is retrieved by calling Cacheable.cacheKey method. |
|
fun <T : Cacheable> getObject(key: String): T?
Returns a object with the given key. |
|
fun <T : Cacheable> removeObject(key: String): <ERROR CLASS><T?, Boolean> |
fun <T : Cacheable> addObject(obj: CacheableContainer): Boolean
Adds an object to persistent store. Assumes that lock is already obtained. |
|
open fun getAllObjects(): List<Cacheable>
Returns a list of all the cached objects. |
|
open fun hashCode(key: String): Int
Returns a hash code for the given key. For example, it may wrap the raw hash code for a string by cache sizeUnsafe. |
|
open fun rehydrate(): Unit
Rehydrates the cache by loading all the cached objects from the persisted stores. It does a total replacement of current cache with the objects loaded from persistent stores and does not perform a merge of any sort. |
|
fun <T : Cacheable> removeObject(obj: CacheableContainer): <ERROR CLASS><T?, Boolean>
Removes the item from persistent stores. Assumes that lock is already obtained. |