Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 2
0
        public CustomerService(ICacheService cacheService, IOrdersRepository ordersRepository, ICustomerRepository customerRepository)
        {
            _cacheService = cacheService;
            _customerRepository = customerRepository;

            GetCustomerDetails =
            _cacheService.Encachify(
                (int i) => string.Format(@"CustomerDetails{0}", i),
                GetCustomerDetailsCore);
        }