Question

I have a repository that pulls from both db, and sometimes a cache.

To implement this, I created an interface ICacheWrapper that lets the repo use HttpRuntime.Cache, AppFabric, whatever. Concrete classes of the ICacheWrapper usually take the cache in their constructor like so: new HttpCacheWrapper(HttpRuntime.Cache)

The repo's constructor takes a reference to a cache wrapper like so:

myRepo = new Repo(new HttpCacheWrapper(HttpRuntime.Cache));

If I create 2 repos, does the cache get deep copied? I would think not, but our performance problems indicate otherwise. Have I missed something here?

Thanks for any help!

Was it helpful?

Solution

What are you seeing? What does HttpCacheWrapper do with the HttpRuntime.Cache it gets passed?

I suspect that what you're seeing instead is a cache policy that holds onto things too long for the rate that things are being cached. As Raymond Chen has said, "incorrect cache policy is indistinguishable from a memory leak."

The way I would isolate this is to try to test with just one repo using the policy you have. See if your performance problems appear.

If not, then go ahead and create the 2nd repo and closely monitor memory usage.

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