Class CacheLoader

java.lang.Object
net.spy.memcached.compat.SpyObject
net.spy.memcached.util.CacheLoader

public class CacheLoader extends SpyObject
CacheLoader provides efficient mechanisms for storing lots of data.
  • Field Details

  • Constructor Details

    • CacheLoader

      public CacheLoader(MemcachedClientIF c)
      Simple CacheLoader constructor that doesn't provide any feedback and caches forever.
      Parameters:
      c - a client
    • CacheLoader

      public CacheLoader(MemcachedClientIF c, ExecutorService es, CacheLoader.StorageListener sl, int exp)
      Get a CacheLoader with all the options.
      Parameters:
      c - a client
      es - an ExecutorService (e.g. thread pool) to dispatch results (may be null, in which case no listener may be provided)
      sl - a storage listener (may be null)
      exp - expiration to use while loading
  • Method Details

    • loadData

      public <T> Future<?> loadData(Iterator<Map.Entry<String,T>> i)
      Load data from the given iterator.
      Type Parameters:
      T - type of data being loaded
      Parameters:
      i - the iterator of data to load
    • loadData

      public <T> Future<?> loadData(Map<String,T> map)
      Load data from the given map.
      Type Parameters:
      T - type of data being loaded
      Parameters:
      map - the map of keys to values that needs to be loaded
    • push

      public <T> Future<Boolean> push(String k, T value)
      Push a value into the cache. This is a wrapper around set that throttles and retries on full queues.
      Type Parameters:
      T - the type being stored
      Parameters:
      k - the key
      value - the value
      Returns:
      the future representing the stored data
    • watch

      private void watch(String key, Future<Boolean> f)