开发者

Replacement suggestions for EntLib PolicyInjection

开发者 https://www.devze.com 2023-02-28 18:21 出处:网络
We currently use Enterprise Library Policy Injection for caching on our data access repository e.g. public interface IClientStatusRepository

We currently use Enterprise Library Policy Injection for caching on our data access repository e.g.

public interface IClientStatusRepository { [CachingCallHandler(24, 0, 0)] IList GetAll(); }

var clientStatusRepository = PolicyInjection.Wrap(new ClientStatusRepository());

This works well for us because its declarative and has absolutely has no configuration files involved. Its also hidden behind our own factory pattern so its easy to replace.

We have started looking at alternative solutions. The main reason for looking at alternatives is that we realised we needed to change the way it currently expires content from the asp.net cache. Also, we want to introduce a distributed cache (MemCached or AppFabric) and want to be able to evict objects declaratively from the Cache

Can anyone suggest some alternatives that they have used ideally with a distributed cache. If the solution requires config per class it will be autom开发者_开发技巧atically ruled out. The Aspects must be declarative in code.

Thanks

Craig


Writing call handlers is fairly straightforward. You also have the caching call handler source as an example. Write a custom call handler that calls the cache system you'd like to use.

Be aware that this caching behavior is harder than it looks, and the Entlib handler made enough mistakes that we pulled it rather than try to fix it for Entlib 5. In particular, it "leaks" results across users in a web project, since the cache is per application. And intelligently forming a cache key in the face of arbitrary parameters of arbitrary types is not an easy problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号