0

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?

Elad Benda
  • 35,076
  • 87
  • 265
  • 471

1 Answers1

1

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".

Community
  • 1
  • 1
tam tam
  • 1,870
  • 2
  • 21
  • 46
  • this is what I was looking for. So in order to bypass my cache for a test, I need to configure `maximumElementsInCacheBeforeScavenging=0`. right? – Elad Benda Jan 15 '13 at 07:18
  • btw, what's the defualt timeSpan for a new item in the cache? – Elad Benda Jan 15 '13 at 07:22
  • The default settings are NeverExpired and Normal. If another item already exists with the same key, that item is removed before the new item is added – tam tam Jan 15 '13 at 15:37
  • this is what I was looking for. So in order to bypass my cache for a test, I need to configure maximumElementsInCacheBeforeScavenging=0. right? – Elad Benda Jan 20 '13 at 08:23
  • Actually that answer is dependent on this "Scavenging" not being a background process which I am thinking it is. While it may be extremely quick you could potentially have a cache hit in that .2 seconds between item being put in cache and the next hit loading it. – Morgeth888 May 02 '18 at 20:16