Search Results for

Show / Hide Table of Contents

# Class CacheParallelLoadStoreAdapter<TK, TV, TData>

Cache storage adapter with parallel loading in LoadAll method.

##### Inheritance

System.Object
CacheParallelLoadStoreAdapter<TK, TV, TData>

##### Implements

ICacheStore<TK, TV>
ICacheStore

###### Namespace: Apache.Ignite.Core.Cache.Store

###### Assembly: Apache.Ignite.Core.dll

##### Syntax

    public abstract class CacheParallelLoadStoreAdapter<TK, TV, TData> : object, ICacheStore<TK, TV>, ICacheStore

##### Type Parameters

Name | Description
--- | ---
TK | Key type.
TV | Value type.
TData | Custom data entry type.

##### Remarks

LoadCache calls GetInputData() and iterates over it in parallel. GetInputData().GetEnumerator() result will be disposed if it implements IDisposable. Any additional post-LoadCache steps can be performed by overriding LoadCache method.

### Constructors

#### CacheParallelLoadStoreAdapter()

Constructor.

##### Declaration

    protected CacheParallelLoadStoreAdapter()

### Properties

#### MaxDegreeOfParallelism

Gets or sets the maximum degree of parallelism to use in LoadCache. Must be either positive or -1 for unlimited amount of threads.

Defaults to .

##### Declaration

    public int MaxDegreeOfParallelism { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

### Methods

#### Delete(TK)

Delete the cache entry from the external resource.

Expiry of a cache entry is not a delete hence will not cause this method to be invoked.

This method is invoked even if no mapping for the key exists.

##### Declaration

    public virtual void Delete(TK key)

##### Parameters

Type | Name | Description
--- | --- | ---
TK | key | The key that is used for the delete operation.

#### DeleteAll(IEnumerable<TK>)

Remove data and keys from the external resource for the given collection of keys, if present.

The order that individual deletes occur is undefined.

If this operation fails (by throwing an exception) after a partial success, the writer must remove any successfully written entries from the entries collection so that the caching implementation knows what succeeded and can mutate the cache.

Expiry of a cache entry is not a delete hence will not cause this method to be invoked.

This method may include keys even if there is no mapping for that key, in which case the data represented by that key should be removed from the underlying resource.

##### Declaration

    public virtual void DeleteAll(IEnumerable<TK> keys)

##### Parameters

Type | Name | Description
--- | --- | ---
IEnumerable<TK> | keys | a mutable collection of keys for entries to delete. Upon invocation, it contains the keys to delete for write-through. Upon return the collection must only contain the keys that were not successfully deleted.

#### GetInputData()

Gets the input data sequence to be used in LoadCache.

##### Declaration

    protected abstract IEnumerable<TData> GetInputData()

##### Returns

Type | Description
--- | ---
IEnumerable<TData> |

#### Load(TK)

Loads an object. Application developers should implement this method to customize the loading of a value for a cache entry. This method is called by a cache when a requested entry is not in the cache. If the object can't be loaded `null` should be returned.

##### Declaration

    public virtual TV Load(TK key)

##### Parameters

Type | Name | Description
--- | --- | ---
TK | key | The key identifying the object being loaded.

##### Returns

Type | Description
--- | ---
TV | The value for the entry that is to be stored in the cache or `null` if the object can't be loaded

#### LoadAll(IEnumerable<TK>)

Loads multiple objects. Application developers should implement this method to customize the loading of cache entries. This method is called when the requested object is not in the cache. If an object can't be loaded, it is not returned in the resulting map.

##### Declaration

    public virtual IEnumerable<KeyValuePair<TK, TV>> LoadAll(IEnumerable<TK> keys)

##### Parameters

Type | Name | Description
--- | --- | ---
IEnumerable<TK> | keys | Keys identifying the values to be loaded.

##### Returns

Type | Description
--- | ---
IEnumerable<KeyValuePair<TK, TV>> | A map of key, values to be stored in the cache.

#### LoadCache(Action<TK, TV>, Object[])

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 LocalLoadCache(ICacheEntryFilter<TK, TV>, 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.

For every loaded value method provided action should be called. The action will then make sure that the loaded value is stored in cache.

##### Declaration

    public virtual void LoadCache(Action<TK, TV> act, params object[] args)

##### Parameters

Type | Name | Description
--- | --- | ---
Action<TK, TV> | act | Action for loaded values.
System.Object[] | args | Optional arguemnts passed to LocalLoadCache(ICacheEntryFilter<TK, TV>, Object[]) method.

##### Exceptions

Type | Condition
--- | ---
CacheStoreException |

#### Parse(TData, Object[])

This method should transform raw data records from GetInputData into valid key-value pairs to be stored into cache.

##### Declaration

    protected abstract KeyValuePair<TK, TV>? Parse(TData inputRecord, params object[] args)

##### Parameters

Type | Name | Description
--- | --- | ---
TData | inputRecord |
System.Object[] | args |

##### Returns

Type | Description
--- | ---
System.Nullable<KeyValuePair<TK, TV>> |

#### SessionEnd(Boolean)

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

##### Declaration

    public virtual void SessionEnd(bool commit)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Boolean | commit | `True` if transaction should commit, `false` for rollback.

#### Write(TK, TV)

Write the specified value under the specified key to the external resource.

This method is intended to support both key/value creation and value update.

##### Declaration

    public virtual void Write(TK key, TV val)

##### Parameters

Type | Name | Description
--- | --- | ---
TK | key | Key to write.
TV | val | Value to write.

#### WriteAll(IEnumerable<KeyValuePair<TK, TV>>)

Write the specified entries to the external resource. This method is intended to support both insert and update.

The order that individual writes occur is undefined.

If this operation fails (by throwing an exception) after a partial success, the writer must remove any successfully written entries from the entries collection so that the caching implementation knows what succeeded and can mutate the cache.

##### Declaration

    public virtual void WriteAll(IEnumerable<KeyValuePair<TK, TV>> entries)

##### Parameters

Type | Name | Description
--- | --- | ---
IEnumerable<KeyValuePair<TK, TV>> | entries | a mutable collection to write. Upon invocation, it contains the entries to write for write-through. Upon return the collection must only contain entries that were not successfully written. (see partial success above).

### Implements

ICacheStore<TK, TV>
ICacheStore