Package org.caffinitas.ohc.linked

Linked memory entry off-heap implementation.

The number of segments is configured via OHCacheBuilder, defaults to # of cpus * 2 and must be a power of 2. Entries are distribtued over the segments using the most significant bits of the 64 bit hash code. Accesses on each segment are synchronized.

Each hash-map entry is allocated individually. Entries are free'd (deallocated), when they are no longer referenced by the off-heap map itself or any external reference like DirectValueAccess or a CacheSerializer.

The design of this implementation reduces the locked time of a segment to a very short time. Put/replace operations allocate memory first, call the CacheSerializers to serialize the key and value and then put the fully prepared entry into the segment.

Eviction is performed using an LRU algorithm. A linked list through all cached elements per segment is used to keep track of the eldest entries.

Since this implementation performs alloc/free operations for each individual entry, take care of memory fragmentation. We recommend using jemalloc to keep fragmentation low. On Unix operating systems, preload jemalloc.