Package net.spy.memcached.util
Class CacheLoader
java.lang.Object
net.spy.memcached.compat.SpyObject
net.spy.memcached.util.CacheLoader
CacheLoader provides efficient mechanisms for storing lots of data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
If you are interested in the results of your data load, this interface will receive them. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MemcachedClientIF
private final ExecutorService
private final int
private final CacheLoader.StorageListener
-
Constructor Summary
ConstructorsConstructorDescriptionSimple CacheLoader constructor that doesn't provide any feedback and caches forever.CacheLoader
(MemcachedClientIF c, ExecutorService es, CacheLoader.StorageListener sl, int exp) Get a CacheLoader with all the options. -
Method Summary
-
Field Details
-
executorService
-
storageListener
-
client
-
expiration
private final int expiration
-
-
Constructor Details
-
CacheLoader
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 clientes
- 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
Load data from the given iterator.- Type Parameters:
T
- type of data being loaded- Parameters:
i
- the iterator of data to load
-
loadData
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
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 keyvalue
- the value- Returns:
- the future representing the stored data
-
watch
-