Package org.graylog2.plugin.lookup
Class LookupCacheKey
java.lang.Object
org.graylog2.plugin.lookup.LookupCacheKey
This class is used as a key in
LookupCache
implementations.
It combines the actual key object and a prefix value to allow the same key to be cached for different data adapters without overwriting each other.
Using a LookupCacheKey
with only a prefix might be used for operations like purging all cache keys for
the given prefix.
Examples:
// Key with prefix and key
LookupCacheKey.create(dataAdapter.id(), "foo");
// Key with prefix only
LookupCacheKey.prefix(dataAdapter.id());
For convenience, this class can be serialized and deserialized with Jackson (see
ObjectMapper
, but we strongly recommend implementing your own
serialization and deserialization logic if you're implementing a lookup cache.
There are no guarantees about binary compatibility of this class across Graylog releases!
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic LookupCacheKey
create
(LookupDataAdapter adapter, Object key) static LookupCacheKey
createFromJSON
(String prefix, Object key) boolean
If the cache key instance does not have a key object, this returns true.abstract Object
key()
abstract String
prefix()
static LookupCacheKey
prefix
(LookupDataAdapter adapter)
-
Constructor Details
-
LookupCacheKey
public LookupCacheKey()
-
-
Method Details
-
prefix
-
key
-
createFromJSON
-
create
-
prefix
-
isPrefixOnly
public boolean isPrefixOnly()If the cache key instance does not have a key object, this returns true.A cache key with only a prefix can be used to operate on all keys for the given prefix. (e.g. cache purge)
- Returns:
- true if there is no key object, false otherwise
-