| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | Memoize.MemoizeNullValue
A place-holder for cached null values |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Memoize. | MEMOIZE_NULL
A place-holder for null values in cache |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static < The closure's return type V> Closure | Returns: A new memoized closureA map to hold memoized return values cache, final Closure<V> The closure to memoize closure)Creates a new closure delegating to the supplied one and memoizing all return values by the arguments. |
| public static < The closure's return type V> Closure | Returns: A new memoized closureThe number of hard references to keep in order to prevent some (LRU) memoized return values from eviction protectedCacheSize, final MemoizeCache<Object, SoftReference<Object>> A map to hold memoized return values cache, final Closure<V> The closure to memoize closure)Creates a new closure delegating to the supplied one and memoizing all return values by the arguments. |
| private static Object | Returns: The key - a list holding all argumentsThe arguments supplied to the closure invocation args)Creates a key to use in the memoize cache |
| MEMOIZE_NULL | back to summary |
|---|---|
| private static final Memoize. A place-holder for null values in cache | |
| Memoize | back to summary |
|---|---|
| public Memoize() | |
| buildMemoizeFunction | back to summary |
|---|---|
| public static <V> Closure Creates a new closure delegating to the supplied one and memoizing all return values by the arguments. The supplied cache is used to store the memoized values and it is the cache's responsibility to put limits on the cache size or implement cache eviction strategy. The LRUCache, for example, allows to set the maximum cache size constraint and implements the LRU (Last Recently Used) eviction strategy.
| |
| buildSoftReferenceMemoizeFunction | back to summary |
|---|---|
| public static <V> Closure Creates a new closure delegating to the supplied one and memoizing all return values by the arguments. The memoizing closure will use SoftReferences to remember the return values allowing the garbage collector to reclaim the memory, if needed. The supplied cache is used to store the memoized values and it is the cache's responsibility to put limits on the cache size or implement cache eviction strategy. The LRUCache, for example, allows to set the maximum cache size constraint and implements the LRU (Last Recently Used) eviction strategy. If the protectedCacheSize argument is greater than 0 an optional LRU (Last Recently Used) cache of hard references is maintained to protect recently touched memoized values against eviction by the garbage collector.
| |
| generateKey | back to summary |
|---|---|
| private static Object generateKey(final Object[] args) Creates a key to use in the memoize cache | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final MemoizeCache | |
| pack-priv final Closure | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public V | call(final Object... args)
Overrides groovy. |
| private static MemoizeCache | |
| public V |
| cache | back to summary |
|---|---|
| pack-priv final MemoizeCache<Object, Object> cache | |
| closure | back to summary |
|---|---|
| pack-priv final Closure<V> closure | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| MemoizeFunction | back to summary |
|---|---|
| pack-priv MemoizeFunction(final MemoizeCache<Object, ?> cache, Closure<V> closure) | |
| call | back to summary |
|---|---|
| public V call(final Object... args) Overrides groovy. Doc from groovy. Invokes the closure with given argument(s), returning any value if applicable.
| |
| coerce | back to summary |
|---|---|
| private static MemoizeCache | |
| doCall | back to summary |
|---|---|
| public V doCall(final Object... args) | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(final Object
the reference object with which to compare. obj)Overrides java. |
| public int |
| MemoizeNullValue | back to summary |
|---|---|
| private MemoizeNullValue() | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final ProtectionStorage | |
| pack-priv final ReferenceQueue | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv | SoftReferenceMemoizeFunction(final MemoizeCache<Object, SoftReference<Object>> cache, Closure<V> closure, ProtectionStorage<K, V> lruProtectionStorage, ReferenceQueue<T> queue)
|
| Modifier and Type | Method and Description |
|---|---|
| public V | call(final Object... args)
Overrides org. |
| private static void | cleanUpNullReferences(final MemoizeCache<Object, Object>
The cache to prune cache, final ReferenceQueue<T> A reference queue holding references to gc-evicted memoized values queue)After the garbage collector has done its job, we need to clean the cache from references to all the evicted memoized values. |
| lruProtectionStorage | back to summary |
|---|---|
| pack-priv final ProtectionStorage<K, V> lruProtectionStorage | |
| queue | back to summary |
|---|---|
| pack-priv final ReferenceQueue<T> queue | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. | |
| SoftReferenceMemoizeFunction | back to summary |
|---|---|
| pack-priv SoftReferenceMemoizeFunction(final MemoizeCache<Object, SoftReference<Object>> cache, Closure<V> closure, ProtectionStorage<K, V> lruProtectionStorage, ReferenceQueue<T> queue) | |
| call | back to summary |
|---|---|
| public V call(final Object... args) Overrides org. Doc from groovy. Invokes the closure with given argument(s), returning any value if applicable.
| |
| cleanUpNullReferences | back to summary |
|---|---|
| private static void cleanUpNullReferences(final MemoizeCache<Object, Object> cache, final ReferenceQueue<T> queue) After the garbage collector has done its job, we need to clean the cache from references to all the evicted memoized values.
| |