Caching WCF client-side with .NET4

2019-08-06 15:54发布

I have a set of entities which which will be retrieved from service. Some of them are static, so i decided to create a client-side cache. But i can not find the point to insert caching. I have svcutil generated proxies and i need to enable caching for some of them (not all). My point is to make some mechanism, that will work in channelFactory/clientBase level and will cache all required entities.

What i want:

  • transparent caching without business logic changing (in common or at all)

  • configuring cacheable entities with some kind of attribute: [Cacheable]

  • ability to add caching implementation: MemoryCache, DistributedCache

2条回答
淡お忘
2楼-- · 2019-08-06 16:18

Whereas, it's very easy to create a Caching Attribute using IOperationInvoker on the service (check an example here), it's very difficult to do the same on client side.

The best example that I've seen is from Paolo Salvatori, available here. Great solution, but I finally gave up because of the complexity. I turned myself to a generic wrapper for WCF calls. There are still manual tasks but it's simpler and I can easily manage it.

查看更多
祖国的老花朵
3楼-- · 2019-08-06 16:25

what about caching with Castle Windsor integration facility? you can intercept and implement cache client side (i did it). weak side: i think this project is not well documented, and also i dont really know how alive it is.

http://docs.castleproject.org/Windsor.WCF-Integration-Facility.ashx

查看更多
登录 后发表回答