Question

I am writing a dll with a number of high-level utility classes, that other developers will consume and use in their applications.

Currently I am working on an implementation of a class, that has to make use of local caching of large strings, otherwise it will be very slow.

Is there a unified cache storage location that I can place my superclass.cache file into (from my code that will go into dll), that will work in any .net app (asp.net also)?

For example I've seen people that write libraries for ASP.Net just make use of AppData folder for this purpose. But if my library is reference in a WPF application, there won't be an AppData folder. Even worse, it may be ran in an environment, where not writing to disk from code is allowed.

This bring us to the question - asking the user to enable caching, and if yes - where is the only (best) option?

UPDATE: Now when I think of Windows Phone being brought into place with it's isolated storage, I better just provide an ICacher interface and let people implement it to be universal I guess.

Was it helpful?

Solution

Assuming this is .Net 4.0, the System.Runtime.Caching namespace is available; this has a MemoryCache class (MSDN), which is a caching class similar to the ASP.NET cache but has no dependency on the System.Web assembly. As part of System.Runtime, this should be available to all types of application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top