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 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 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. User can change 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 Enterprise Edition.
In this scheme a counter that counts the access made to an object is used. At the time of eviction objects with lowest counter value are evicted first. Here too a random selection is made between two objects with same counter.
- Least Recently Used
Note
This feature is only available in Enterprise Edition.
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 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 cache. Objects with lower priority are removed before objects with higher cost. Client application can choose from a list of priorities that is pre-defined (Low, Below Normal, Normal, Above Normal, High and Not Removable). In order to get 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 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 NCache install directory. In config.ncconf of EACH server add the <eviction-policy>
tag under <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%, default value will be used. Eviction is not recommended in case of sessions.
Note
Repeat this step for all server nodes.
See Also
Configure Caches
Configure Clients
Cache Level Events
General Cache Settings