org.hibernate.util

Class SoftLimitMRUCache

Implemented Interfaces:
Serializable

public class SoftLimitMRUCache
extends java.lang.Object
implements Serializable

Cache following a "Most Recently Used" (MRY) algorithm for maintaining a bounded in-memory size; the "Least Recently Used" (LRU) entry is the first available for removal from the cache.

This implementation uses a "soft limit" to the in-memory size of the cache, meaning that all cache entries are kept within a completely java.lang.ref.SoftReference-based map with the most recently utilized entries additionally kept in a hard-reference manner to prevent those cache entries soft references from becoming enqueued by the garbage collector. Thus the actual size of this cache impl can actually grow beyond the stated max size bound as long as GC is not actively seeking soft references for enqueuement.

Author:
Steve Ebersole

Field Summary

static int
DEFAULT_STRONG_REF_COUNT

Constructor Summary

SoftLimitMRUCache()
SoftLimitMRUCache(int strongRefCount)

Method Summary

void
clear()
Object
get(Object key)
Object
put(Object key, Object value)
int
size()
int
softSize()

Field Details

DEFAULT_STRONG_REF_COUNT

public static final int DEFAULT_STRONG_REF_COUNT
Field Value:
128

Constructor Details

SoftLimitMRUCache

public SoftLimitMRUCache()

SoftLimitMRUCache

public SoftLimitMRUCache(int strongRefCount)

Method Details

clear

public void clear()

get

public Object get(Object key)

put

public Object put(Object key,
                  Object value)

size

public int size()

softSize

public int softSize()