Configure Eviction Policy
If a cache reaches its maximum storage limit and Eviction is turned on, 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 Eviction is turned off, items are neither evicted nor added to the cache any further.
An Eviction scheme is used to select the objects that need 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 only if it is not running. Three types of Eviction Policies are provided by 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 time stamp, a random selection is made.
- Priority Based Eviction
This is the default Eviction Policy with the addition of a relative cost that is associated with an object at the time of its addition to the cache. Objects with lower priority are removed before objects with higher cost. The client application can choose from a pre-defined list of priorities (Low, Below Normal, Normal, Above Normal, High, and Not Removable). To get a more detailed explanation of Eviction please see the Eviction section.
Manually Editing NCache Configuration
You can manually edit config.ncconf and client.ncconf located at %NCHOME%/config. %NCHOME% is the NCache install directory. 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 to follow the set of steps.
Eviction is enabled by default. Specify the Eviction Policy for a cache through config.ncconf file located at %NCHOME%\config. %NCHOME%
is the NCache install directory. In config.ncconf 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
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%, the default value will be used. Eviction is not recommended in the case of sessions.
Note
Repeat this step for all server nodes.
See Also
Configure Caches
Configure Clients
Cache Level Events
General Cache Settings