org.apache.ignite.internal.processors.cache

## Class CacheStoreBalancingWrapper<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper<K,V>

All Implemented Interfaces:
  javax.cache.integration.CacheLoader<K,V>, javax.cache.integration.CacheWriter<K,V>, CacheStore<K,V>

    public class CacheStoreBalancingWrapper<K,V>
    extends Object
    implements CacheStore<K,V>

Cache store wrapper that ensures that there will be no more that one thread loading value from underlying store.

### Field Summary

Fields
`static int` `DFLT_LOAD_ALL_THRESHOLD`

### Constructor Summary

Constructors
Constructor and Description
`CacheStoreBalancingWrapper(CacheStore<K,V> delegate)`
`CacheStoreBalancingWrapper(CacheStore<K,V> delegate, int loadAllThreshold)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `delete(Object key)`
`void` `deleteAll(Collection<?> keys)`
`V` `load(K key)`
`void` `loadAll(Collection<? extends K> keys, IgniteBiInClosure<K,V> c)`
`Map<K,V>` `loadAll(Iterable<? extends K> keys)`
`int` `loadAllThreshold()`
`void` `loadCache(IgniteBiInClosure<K,V> clo, Object... args)` Loads all values from underlying persistent storage.
`void` `sessionEnd(boolean commit)` Tells store to commit or rollback a transaction depending on the value of the `'commit'` parameter.
`String` `toString()`
`void` `write(javax.cache.Cache.Entry<? extends K,? extends V> entry)`
`void` `writeAll(Collection<javax.cache.Cache.Entry<? extends K,? extends V>> entries)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### DFLT_LOAD_ALL_THRESHOLD

    public static final int DFLT_LOAD_ALL_THRESHOLD

See Also:
  Constant Field Values

### Constructor Detail

#### CacheStoreBalancingWrapper

    public CacheStoreBalancingWrapper(CacheStore<K,V> delegate)

Parameters:
  `delegate` - Delegate store.

#### CacheStoreBalancingWrapper

    public CacheStoreBalancingWrapper(CacheStore<K,V> delegate,
                                      int loadAllThreshold)

Parameters:
  `delegate` - Delegate store.
  `loadAllThreshold` - Load all threshold.

### Method Detail

#### loadAllThreshold

    public int loadAllThreshold()

Returns:
  Load all threshold.

#### load

    @Nullable
    public V load(K key)

Specified by:
  `load` in interface `javax.cache.integration.CacheLoader<K,V>`

#### loadCache

    public void loadCache(IgniteBiInClosure<K,V> clo,
                          @Nullable
                          Object... args)

Loads all values from underlying persistent storage. Note that keys are not passed, so it is up to implementation to figure out what to load. This method is called whenever `IgniteCache.loadCache(IgniteBiPredicate, Object...)` method is invoked which is usually to preload the cache from persistent storage.

This method is optional, and cache implementation does not depend on this method to do anything. Default implementation of this method in `CacheStoreAdapter` does nothing.

For every loaded value method `IgniteBiInClosure.apply(Object, Object)` should be called on the passed in closure. The closure will then make sure that the loaded value is stored in cache.

Specified by:
  `loadCache` in interface `CacheStore<K,V>`
Parameters:
  `clo` - Closure for loaded values.
  `args` - Arguments passes into `IgniteCache.loadCache(IgniteBiPredicate, Object...)` method.

#### loadAll

    public Map<K,V> loadAll(Iterable<? extends K> keys)
                     throws javax.cache.integration.CacheLoaderException

Specified by:
  `loadAll` in interface `javax.cache.integration.CacheLoader<K,V>`
Throws:
  `javax.cache.integration.CacheLoaderException`

#### loadAll

    public void loadAll(Collection<? extends K> keys,
                        IgniteBiInClosure<K,V> c)

Parameters:
  `keys` - Keys to load.
  `c` - Closure for loaded values.

#### write

    public void write(javax.cache.Cache.Entry<? extends K,? extends V> entry)

Specified by:
  `write` in interface `javax.cache.integration.CacheWriter<K,V>`

#### writeAll

    public void writeAll(Collection<javax.cache.Cache.Entry<? extends K,? extends V>> entries)

Specified by:
  `writeAll` in interface `javax.cache.integration.CacheWriter<K,V>`

#### delete

    public void delete(Object key)
                throws javax.cache.integration.CacheWriterException

Specified by:
  `delete` in interface `javax.cache.integration.CacheWriter<K,V>`
Throws:
  `javax.cache.integration.CacheWriterException`

#### deleteAll

    public void deleteAll(Collection<?> keys)
                   throws javax.cache.integration.CacheWriterException

Specified by:
  `deleteAll` in interface `javax.cache.integration.CacheWriter<K,V>`
Throws:
  `javax.cache.integration.CacheWriterException`

#### sessionEnd

    public void sessionEnd(boolean commit)

Tells store to commit or rollback a transaction depending on the value of the `'commit'` parameter.

Specified by:
  `sessionEnd` in interface `CacheStore<K,V>`
Parameters:
  `commit` - `True` if transaction should commit, `false` for rollback.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.6.0
Release Date | : July 10 2018