private static class FastFindCache.ReverseLookup
extends java.lang.Object
Important implementation note: it is imperative that only a "canonical" RecordIdentifier
is used as a key in this reverse cache. The same canonical instance of the record
identifier must be used as the cached result in the primary cache (i.e., at the L3 level). Not doing
so can cause a memory leak, because we use a weak map for this reverse cache. This is necessary
because bulk invalidation (i.e., for an entire table or set of indices) can "orphan" entries in this
reverse cache. However, if only canonical RecordIdentifier
instances are used as keys for
this cache (and as values in the primary, L3 caches), any orphaned entries in this reverse cache will
be cleaned up eventually during garbage collection.
The getCanonicalRecordIdentifier(RecordIdentifier)
method is used to retrieve
a canonical RecordIdentifier
.
Modifier and Type | Class and Description |
---|---|
private static class |
FastFindCache.ReverseLookup.Node
A node containing information required to invalidate a single, L3 cached result.
|
private static class |
FastFindCache.ReverseLookup.Value
The value object in the reverse cache, which contains the information needed to invalidate all
cached results associated with the
RecordIdentifier keys in the reverse cache. |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<RecordIdentifier<java.lang.String>,FastFindCache.ReverseLookup.Value> |
cache
Weak map of canonical record identifiers to information needed to invalidate cache entries
|
Modifier | Constructor and Description |
---|---|
private |
ReverseLookup() |
Modifier and Type | Method and Description |
---|---|
(package private) RecordIdentifier<java.lang.String> |
getCanonicalRecordIdentifier(RecordIdentifier<java.lang.String> recID)
Get the canonical instance of the given
RecordIdentifier . |
(package private) void |
invalidate(RecordIdentifier<java.lang.String> recID,
java.util.BitSet dirtyProps)
If any cached results with non-indexed properties are associated with the given record identifier,
invalidate each result whose FQL's non-indexed properties intersect with the given set of dirty
properties.
|
(package private) void |
put(RecordIdentifier<java.lang.String> recID,
Cache<FastFindCache.L2Key,RecordIdentifier<java.lang.String>> l3Cache,
FastFindCache.L2Key l2Key)
Add an entry to the reverse cache.
|
private final java.util.Map<RecordIdentifier<java.lang.String>,FastFindCache.ReverseLookup.Value> cache
void put(RecordIdentifier<java.lang.String> recID, Cache<FastFindCache.L2Key,RecordIdentifier<java.lang.String>> l3Cache, FastFindCache.L2Key l2Key)
recID
- Unique record identifier, which may represent one or more primary cache entries.l3Cache
- The third level of the primary cache, in which a cache result for the given record
identifier is stored.l2Key
- The key used to identify a cached result in the l3Cache
.RecordIdentifier<java.lang.String> getCanonicalRecordIdentifier(RecordIdentifier<java.lang.String> recID)
RecordIdentifier
.recID
- A record identifier.RecordIdentifier
instance for recID
. If there is not yet a
reverse lookup entry for recID
, it is returned as the canonical instance.void invalidate(RecordIdentifier<java.lang.String> recID, java.util.BitSet dirtyProps)
recID
- Record identifier of any cached result which might require invalidation.dirtyProps
- The set of properties touched by an update. For performance reasons, we do not compare
the old and new values of each property, only check whether the property was touched.