public final class Caches
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Caches.ClearableCache<K,V>
A cache that tracks keys that have been inserted into the cache and supports clearing them.
|
| Modifier and Type | Field and Description |
|---|---|
static long |
REFERENCE_SIZE
The size of a reference.
|
| Constructor and Description |
|---|
Caches() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> Cache<K,V> |
eternal()
A cache that never evicts any values.
|
static <K,V> Cache<K,V> |
fromOptions(org.apache.beam.sdk.options.PipelineOptions options)
Uses the specified
PipelineOptions to configure and return a cache instance based upon
parameters within SdkHarnessOptions. |
static <K,V> Cache<K,V> |
noop()
A cache that never stores any values.
|
static boolean |
shouldUpdateOnSizeChange(long oldSize,
long newSize)
Returns whether the cache should be updated in the case where the objects size has changed.
|
static <K,V> Cache<K,V> |
subCache(Cache<?,?> cache,
java.lang.Object keyPrefix,
java.lang.Object... additionalKeyPrefix)
Returns a view of a cache that operates on keys with a specified key prefix.
|
static long |
weigh(java.lang.Object o)
Returns the amount of memory in bytes the provided object consumes.
|
public static final long REFERENCE_SIZE
public static long weigh(java.lang.Object o)
public static boolean shouldUpdateOnSizeChange(long oldSize,
long newSize)
Note that this should only be used in the case where the cache is being updated very often in a tight loop and is not a good fit for cases where the object being cached is the result of an expensive operation like a disk read or remote service call.
public static <K,V> Cache<K,V> noop()
public static <K,V> Cache<K,V> eternal()
public static <K,V> Cache<K,V> fromOptions(org.apache.beam.sdk.options.PipelineOptions options)
PipelineOptions to configure and return a cache instance based upon
parameters within SdkHarnessOptions.public static <K,V> Cache<K,V> subCache(Cache<?,?> cache, java.lang.Object keyPrefix, java.lang.Object... additionalKeyPrefix)
All lookups, insertions, and removals into the parent Cache will be prefixed by the
specified prefixes.