Interface CacheMap<T>

All Known Implementing Classes:
HazelcastMapAdapter, InMemoryCacheMap, MVStoreCacheMap

public interface CacheMap<T>
  • Method Details

    • isEmpty

      boolean isEmpty()
    • put

      void put(String key, T value)
    • putAll

      void putAll(Map<String,T> entries)
    • get

      Optional<T> get(String key)
    • remove

      void remove(String key)
    • clear

      void clear()
    • computeIfAbsent

      T computeIfAbsent(String key, Function<String,? extends T> mappingFunction)
    • computeIfPresent

      Optional<T> computeIfPresent(String key, BiFunction<String,? super T,? extends T> remappingFunction)
    • compute

      Optional<T> compute(String key, BiFunction<String,? super T,? extends T> remappingFunction)
    • merge

      T merge(String key, T value, BiFunction<? super T,? super T,? extends T> remappingFunction)
    • containsKey

      boolean containsKey(String key)
    • getOrDefault

      T getOrDefault(String key, T defaultValue)
    • putIfAbsent

      T putIfAbsent(String key, T value)
      If the specified key is not already associated with a value, associates it with the given value. This is equivalent to, for this cache:
       if (!cache.containsKey(key))
           return map.put(key, value);
       else
           return map.get(key);
      
      except that the action is performed atomically.
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      Returns:
      the previous value associated with the specified key, or null if there was no mapping for the key.
    • replace

      boolean replace(String key, T oldValue, T newValue)
    • query

      List<T> query(QueryFilter filter)
      Queries the cache for entries matching the given query filter. Note: This method loads all results into memory at once. For large result sets, consider using queryIterator(com.norconex.crawler.core.cluster.QueryFilter) instead.
      Parameters:
      filter - the query filter
      Returns:
      a list of matching entries or an empty list (never null)
    • queryIterator

      Iterator<T> queryIterator(QueryFilter filter)
      Queries the cache for entries matching the given filter and returns an iterator for memory-efficient processing of results. This avoids loading all results into memory at once.
      Parameters:
      filter - the query filter
      Returns:
      an iterator over the matching entries
    • count

      long count(QueryFilter filter)
      Counts the number of entries matching the given query filter.
      Parameters:
      filter - the query filter
      Returns:
      the count of matching entries
    • size

      long size()
      Counts the number of entries in this cache.
      Returns:
      the number of entries
    • delete

      void delete(QueryFilter filter)
      Deletes entries matching the given query filter.
      Parameters:
      filter - the query filter
    • forEach

      void forEach(BiConsumer<String,? super T> action)
    • keys

      List<String> keys()
      Returns all keys in this cache. For distributed caches, this includes keys from all nodes in the cluster, not just locally-owned keys.
      Returns:
      a list of all keys in the cache
    • loadAll

      default void loadAll()
      Eagerly loads all entries from the backing store (e.g., JDBC) into this cache. For caches configured with LAZY initial load mode, this ensures sub­sequent size(), forEach(java.util.function.BiConsumer<java.lang.String, ? super T>), and keys() calls return correct results. If the cache already has its data loaded (e.g., EAGER mode), this is a no-op.
    • isPersistent

      boolean isPersistent()
      Returns whether this cache persists data across restarts.
      Returns:
      true if the cache is persistent, false if ephemeral
    • getName

      String getName()
      Gets the name of this cache.
      Returns:
      cache name