Class LookupCacheKey

java.lang.Object
org.graylog2.plugin.lookup.LookupCacheKey

public abstract class LookupCacheKey extends Object
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 Details

    • LookupCacheKey

      public LookupCacheKey()
  • Method Details

    • prefix

      public abstract String prefix()
    • key

      @Nullable public abstract Object key()
    • createFromJSON

      public static LookupCacheKey createFromJSON(String prefix, @Nullable Object key)
    • create

      public static LookupCacheKey create(LookupDataAdapter adapter, @Nullable Object key)
    • prefix

      public static LookupCacheKey prefix(LookupDataAdapter adapter)
    • 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