Eviction Policy Configuration
If a cache reaches its maximum storage limit and employs eviction, the specified ratio of items will be evicted to make space for new objects. On the other hand, if the cache reaches its maximum storage limit and doesn't use eviction, items are neither evicted nor added to the cache any further.
An eviction scheme selects the objects to be removed from the cache. A particular eviction policy can be selected at the creation time, but once it is set, it cannot be altered in the running cache. Users can change the eviction policy after creating a cache if it is not running. Three types of Eviction Policies are provided by NCache.
Types of Eviction Policies in NCache
- Least Frequently Used
Note
This feature is only available in NCache Enterprise.
In this scheme, a counter that counts the access made to an object is used. At the time of eviction, objects with the lowest counter value are evicted first. Here, a random selection is made between two objects with the same counter.
- Least Recently Used
Note
This feature is only available in NCache Enterprise.
This eviction scheme associates a timestamp with all objects. This timestamp is updated each time the object is accessed. When evicting, objects with the oldest timestamp are picked first. In the case of two objects with the same timestamp, a random selection is made.
- Priority Based Eviction
This is the default eviction policy with the addition of a relative cost associated with an object at the time of its addition to the cache. Objects with lower priority are removed before objects with higher priority. The client application can choose from a pre-defined list of priorities (Low, Below Normal, Normal, Above Normal, High, and Not Removable). For further details, please refer to the Eviction section.
Note
%NCHOME%
is the NCache install directory.
For NCache Open Source, you can manually edit config.ncconf and client.ncconf located at %NCHOME%\config. These files can be edited through any text editor of your choice.
Important
In case you want to update any cache settings, please refer to the Update Cache Config section.
Eviction is enabled by default. Specify the Eviction Policy for a cache through config.ncconf file located at %NCHOME%\config. In config.ncconf configuration of EACH server, add the <eviction-policy>
tag under the <cache-settings>
tag.
<cache-config>
<cache-settings ...>
<eviction-policy default-priority="normal" eviction-ratio="5%"/>
</cache-settings>
</cache-config>
Important
The eviction-ratio=5%
is equal to 5% of total cache size. The minimum value used for eviction-ratio will be 5%. If the value provided is below 5%, default value will be used. Eviction is not recommended in case of sessions.
Note
Repeat this step for all server nodes.