How to Configure and Use Eviction in NCache

A cache always has a limited size to which it can add objects to it. When a distributed cache reaches its maximum storage size with eviction turned on, a specified ratio of items start evicting from cache in order to create space for new objects. If cache reaches its maximum storage limit and eviction is turned off, items will neither be evicted nor added to the cache any further.

If you have deployed cache in a system where information transactions are occurring very frequently and you want to ensure every new piece of information gets space in cache then the eviction option in NCache should be turned on.

Turning on eviction

You can enable Eviction Policy for both Clustered (Distributed) and Local Cache. Here is how you can turn on eviction from NCache Manager:

  • Launch NCache Manager
  • Click on the Policies tab (If tab pane is not there, double-click on the cache to show the tabs)
  • Set the eviction policy using the drop-down menus on the Policies tab, as shown in the figure below:

How to Configure and Use Eviction in NCache

You can choose from the following Eviction policies on the Policies Tab of the NCache Manager:

LRU (Least Recently Used)

This eviction scheme puts a timestamp on cache objects. The timestamp is updated each time the object is accessed. When evicting, objects with the oldest timestamp are chosen. In a case where two objects have the same time stamp, a random selection between the two will be made.

LFU (Least Frequently Used)

This scheme uses a counter that counts the number of times an object is accessed. At the time of eviction, objects with lowest access count will be evicted first. In this scheme, too, a random selection will be made between the two objects with same count value.

Priority Based

Priority based Eviction is set by default on every cache you create with NCache. Priority based eviction has a similar eviction mechanism as of LFU but with the addition of cost associated with the object at time of caching. Objects with lower cost are removed first and the objects with higher cost are removed later. In priority based eviction policy, you have options of choosing from the following eviction priorities:

  • Low
  • Below Normal
  • Normal
  • Above Normal
  • High

Note: When a priority is not selected, Normal priority will be used as default.

You can also set eviction percentage in the Eviction Percentage textbox to specify percentage of items to be removed from the cache. Setting eviction percentage to 10 will mean that 10% of the cached items will be removed when the eviction occurs. Evictions are only used for object caching and not for session caching, sessions should not be evicted rather they should be timed out. Also, for sessions, users must ensure that they have enough cache size allocated to accommodate all sessions from their user in a peak load time.


What to Do Next?


Signup for monthly email newsletter to get latest updates.

Contact Us


+1 (214) 764-6933 (US)

+44 20 7993 8327 (UK)

© Copyright Alachisoft 2002 - . All rights reserved.