Search code examples
c#asp.netenterprise-library

how to set enterprise library cache size to 1


My web application uses enterpriseLibrary cache

how can I set the cache size to be of size n?

Is it a count of objects? or bite size?


Solution

  • As far as I know enterprise library will not provide you cache size or size of the objects in cache.

    You could read the following answers to find the object size in .NET:

    Find out the size of a .net object

    How to get object size in memory?

    Then in your web configuration file, you could use the following properties to configure:

    maximumElementsInCacheBeforeScavenging

    Scavenging means that the cache attempts to remove infrequently used or unimportant items if memory becomes low. As the name suggests, this setting is used to set the scavenging policies. This defines the maximum number of elements in the cache before the item should be scavenged from cache. By default, it is "1000".

    numberToRemoveWhenScavenging

    The number of remove items defined in the numberToRemoveWhenScavenging setting will be removed from cache from during the scavenging process. The default value for the Remove Scavenging item from cache is "10".