Interface CacheLoader


public interface CacheLoader
Interface for loading cache data from external sources. Implementations provide custom logic to load keys and values from various sources (databases, files, external APIs, etc.) during cache warming.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Get the total number of available keys in the external source.
    getKeys(long offset, long limit)
    Get a batch of keys from the external source for bulk loading.
    Load values for the given keys from an external source.
  • Method Details

    • loadKeys

      Map<String,String> loadKeys(List<String> keys) throws Exception
      Load values for the given keys from an external source.
      Parameters:
      keys - the list of keys to load
      Returns:
      a map of key -> value pairs that were successfully loaded. Keys not found in the external source should be omitted.
      Throws:
      Exception - if loading fails
    • getKeyCount

      long getKeyCount() throws Exception
      Get the total number of available keys in the external source. Used for progress estimation during warming.
      Returns:
      the count of available keys, or -1 if unknown
      Throws:
      Exception - if counting fails
    • getKeys

      List<String> getKeys(long offset, long limit) throws Exception
      Get a batch of keys from the external source for bulk loading. Used to discover available keys during warming when keys are not pre-specified.
      Parameters:
      offset - the starting offset for pagination
      limit - the maximum number of keys to return
      Returns:
      a list of keys, or empty list if no more keys
      Throws:
      Exception - if fetching fails