0
的高速缓存的实现我有一个服务接口,ICustomerService,并经两种实现:城堡温莎 - 注册和解析缓存和相同的接口
public class CustomerService : ICustomerService
{
// stuff
}
public class CachedCustomerService : ICustomerService
{
public CachedCustomerService(CustomerService service) { }
}
缓存服务的话,只是缓存和代表正常服务。
对于注册我已将ICustomerService解析为CachedCustomerService,然后CustomerService仅针对其自己的类型注册。
这工作正常。
我想知道的是,如果我可以使CachedCustomerService需要一个接口,而不是具体的CustomerService。原因是我们可能最终得到两种类型的CustomerService,并且我想避免(如果可能)每个特定的缓存版本。
所以CachedCustomerService的构造函数将变为:
public class CachedCustomerService : ICustomerService
{
// notice the ICustomerService
public CachedCustomerService(ICustomerService service) { }
}
我有过登记总量控制,但分辨率由asp.net的MVC的碗完成。
谢谢!