Interface Option.CacheKeyUpdater<T>

Type Parameters:
T - The type of the option.
Enclosing class:
Option<T>

public static interface Option.CacheKeyUpdater<T>
An interface that updates a MessageDigest with the given value as part of a process to generate a disk cache key.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    update(byte[] keyBytes, T value, MessageDigest messageDigest)
    Updates the given MessageDigest with the bytes of the given key (to avoid incidental value collisions when values are not particularly unique) and value.
  • Method Details

    • update

      void update(@NonNull byte[] keyBytes, @NonNull T value, @NonNull MessageDigest messageDigest)
      Updates the given MessageDigest with the bytes of the given key (to avoid incidental value collisions when values are not particularly unique) and value.

      If your Option shouldn't affect the disk cache key, you should not implement this class and use Option.memory(String) or Option.memory(String, Object) instead.

      Parameters:
      keyBytes - The bytes of the String used as the key for this particular Option. Should be added to the messageDigest using MessageDigest.update(byte[]) by all implementations if the digest is updated with the given value parameter.
      value - The value of of this particular option. Typically you should convert the value to a byte array using some stable mechanism and then call MessageDigest.update(byte[]) to update the given digest.