1

our project uses HttpRuntime.Cache.Get and HttpRuntime.Cache.Insert for storing and retrieving data from the cache.

Is it possible to store this cache in a SQL server database?

By data I am referring to all sorts of different object types.

1
  • Well i think it is possible..but i am wondering how effective it will be to use the cache info from database.. Commented Oct 4, 2012 at 11:22

1 Answer 1

2

The HttpRuntime Cache is bound to the appdomain of the current application and you can control how it is stored. It does smart management on the cache, like clearing objects before there lifespan in the cache is over when you are low on memory. The main point of having the cache in memory is realy fast access to your cached objects. You have no control in where or how the data is stored.

If you have some reason to store the data out of your process, you have the possiblity to implement your own caching.

public class DatasetStore : MarshalByRefObject
{
   // A hash table-based data store
   private Hashtable htStore = new Hashtable();
   //Returns a null lifetime manager so that GC won't collect the object 
   public override object InitializeLifetimeService() {  return null; }

   // Your custom cache interface
}

For example you can share this cache between multiple appdomains.

MSDN Understanding Caching Technologies

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.