public abstract class LookupCacheKey extends Object
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 and Description |
|---|
LookupCacheKey() |
| Modifier and Type | Method and Description |
|---|---|
static LookupCacheKey |
create(LookupDataAdapter adapter,
Object key) |
static LookupCacheKey |
createFromJSON(String prefix,
Object key) |
boolean |
isPrefixOnly()
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) |
public abstract String prefix()
public static LookupCacheKey createFromJSON(String prefix, @Nullable Object key)
public static LookupCacheKey create(LookupDataAdapter adapter, @Nullable Object key)
public static LookupCacheKey prefix(LookupDataAdapter adapter)
public boolean isPrefixOnly()
A cache key with only a prefix can be used to operate on all keys for the given prefix. (e.g. cache purge)
Copyright © 2012–2021 Graylog, Inc.. All rights reserved.