[英]Should Castle DynamicProxy IInterceptor or ProxyGenerator be cached?
I'm using StructureMap to Enrich some of my objects with an instance call to 我正在使用StructureMap通过实例调用来丰富我的一些对象
ProxyGenerator.CreateInterfaceProxyWithTarget(myObject, MYInterceptor)
Currently I have the MYInterceptor
inside my container, should I implement any type of caching for the interceptor? 当前我的容器中有
MYInterceptor
,我应该为拦截器实现任何类型的缓存吗?
The second question should I register my ProxyGenerator
inside my container and if so, should I apply any type of caching to it? 第二个问题是我
ProxyGenerator
在容器内注册ProxyGenerator
吗?如果要注册,应该对它应用任何类型的缓存吗?
you most likely want to reuse the same ProxyGenerator to take advantage of its proxy type caching capabilities. 您很可能希望重用同一ProxyGenerator以利用其代理类型缓存功能。
About the interceptor - it depends. 关于拦截器-这取决于。 Is it purely functional?
它纯粹是功能性的吗? Does it have its own state?
它有自己的状态吗? There's no general rule for that, so you need to decide whether you need a new instance for each new proxy, or can the same instance be reused (which makes sense almost exclusively when interceptor has no state on its own)
对此没有一般性规则,因此您需要确定每个新代理是否需要一个新实例,还是可以重用同一实例(当拦截器自身没有状态时,这几乎是唯一有意义的)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.