使用.NET4缓存WCF客户端 [英] Caching WCF client-side with .NET4

查看:80
本文介绍了使用.NET4缓存WCF客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组实体,将从服务中检索这些实体。
其中一些是静态的,因此我决定创建一个客户端缓存。
但是我找不到插入缓存的意义。我有svcutil生成的代理,我需要为其中一些(不是全部)启用缓存。
我的观点是制定某种机制,该机制将在channelFactory / clientBase级别上运行,并将缓存所有必需的实体。

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.

我想要的东西:


  • 透明缓存,无需更改业务逻辑(共同或根本不更改)

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

使用某种属性配置可缓存实体:[可缓存]

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

添加缓存实现的能力:MemoryCache,DistributedCache

ability to add caching implementation: MemoryCache, DistributedCache

推荐答案

而使用 IOperationInvoker 上的服务(检​​查示例这里),很难在客户端执行相同的操作。

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.

我见过的最好的例子是Paolo Salvatori提供的此处。很好的解决方案,但是由于复杂性,我最终放弃了。我转向WCF调用的通用包装器。仍然有手动任务,但是它比较简单,我可以轻松地进行管理。

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.

这篇关于使用.NET4缓存WCF客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆