Method SetClientCache
SetClientCache(string, int, int)
Sets in-process client cache policies for this cache. Overrides the config file's clientCacheEviction, clientCacheCapacity, and partitionCount settings for this cache.
public CacheBuilder<TKey, TValue> SetClientCache(string eviction, int capacity, int partitionCount)
Parameters
eviction
stringThe eviction policy for the cache (either "LRU", "Random", "LRU-MaxMemory", or "Random-MaxMemory").
capacity
intThe max number of items in the cache before eviction begins, or, if "LRU-MaxMemory" or "Random-MaxMemory" is used, the max memory in megabytes that the cache may hold before eviction begins. Use zero to disable the client cache.
partitionCount
intThe number of partitions in the client cache. If zero, the partition count will equal the number of logical processors on the machine.
Returns
- CacheBuilder<TKey, TValue>
A builder object that can be used to further configure the cache.
Remarks
Increasing the partition count of the in-process client cache will help reduce locking contention in the provided client cache implementations. However, more partitions will decrease the accuracy of LRU eviction--each partition maintains its own independent LRU list, so an evicted object may not be the least-recently accessed objects across all the partitions.
SetClientCache(string, int)
Sets in-process client cache policies for this cache. Overrides the config file's clientCacheEviction, clientCacheCapacity, and partitionCount settings for this cache. A single partition is used.
public CacheBuilder<TKey, TValue> SetClientCache(string eviction, int capacity)
Parameters
eviction
stringThe eviction policy for the cache (either "LRU", "Random", "LRU-MaxMemory", or "Random-MaxMemory").
capacity
intThe max number of items in the cache before eviction begins, or, if "LRU-MaxMemory" or "Random-MaxMemory" is used, the max memory in megabytes that the cache may hold before eviction begins. Use zero to disable the client cache.
Returns
- CacheBuilder<TKey, TValue>
A builder object that can be used to further configure the cache.
SetClientCache(ClientCache<TValue>)
Sets an in-process client cache implementation to be used by the cache. The config file's clientCacheEviction and clientCacheCapacity settings are ignored if a client cache instance is provided to this call. Pass null to disable the client cache.
public CacheBuilder<TKey, TValue> SetClientCache(ClientCache<TValue> clientCache)
Parameters
clientCache
ClientCache<TValue>A client cache implementation derived from ClientCache<TValue>. Passing null disables client caching.
Returns
- CacheBuilder<TKey, TValue>
A builder object that can be used to further configure the cache.