KellyLynch
KellyLynch

Reputation: 251

Caching in ASP.NET for large objects

I have an ASP.NET application. It uses class System.Web.Caching.Cache to cache (for several minutes) some objects. This solution works OK; but sometimes (not often) the objects may be too large to fit into memory. Is there a simple solution to set, say, some ‘swap mode’ for the System.Web.Caching.Cache? I mean – to not try to keep such object in memory, but to save it on disk. Or some other simple solution?

Upvotes: 2

Views: 395

Answers (2)

Magnus
Magnus

Reputation: 46929

You probably should cache those objects, but one solution could be to write a wrapper around System.Web.Caching.Cache. When you add objects to it have an option to serialize them to disk. Getting back the objects from disk will be considerably slower than from the cache.

Upvotes: 0

Dan Diplo
Dan Diplo

Reputation: 25339

You can always write your own implementation of an OutPutCacheProvider to work like you want. Gal Ratner has an example of a Cache Provider that stores objects on disk as zip files, for instance. Or there is this article on CodePlex about it.

Upvotes: 1

Related Questions