public FuncyCustomerService(ICacheService cacheService, ICustomerRepository customerRepository) { _cacheService = cacheService; _customerRepository = customerRepository; // Get the Func from the Encachify extension method. It's just a Func, it won't be called yet! GetCustomerDetails = _cacheService.Encachify( (int customerId) => string.Format(@"CustomerId{0}", customerId), // Pass in a way to make the cache key GetCustomerDetailsCore); // and a way to get the data, if not in the cache }
public CustomerService(ICacheService cacheService, IOrdersRepository ordersRepository, ICustomerRepository customerRepository) { _cacheService = cacheService; _customerRepository = customerRepository; GetCustomerDetails = _cacheService.Encachify( (int i) => string.Format(@"CustomerDetails{0}", i), GetCustomerDetailsCore); }