public CacheConfiguration BuildConfiguration()
        {
            var fixedForOneHour = new CacheInstruction(CacheType.Fixed, TimeSpan.FromHours(1));
            var cacheConfig     = new CacheConfiguration();

            cacheConfig.ApplyCachingOn(x => x.DeclaringType.Name.EndsWith("Repository"), fixedForOneHour)
            .InvalidateOn(x => x.Name.StartsWith("Save"))
            .InvalidateOn(x => x.Name.StartsWith("Delete"))
            .InvalidateOn(x => x.Name.StartsWith("Update"));

            //apply exceptions
            //cacheConfig
            //    .ExceptFor<IPersonRepository>(x => x.GetByName(null))
            //    .InvalidateOn<IPersonRepository>(x => x.Save(null));
            return(cacheConfig);
        }
예제 #2
0
 public CacheConfiguration ApplyCachingOn(Func <MemberInfo, bool> cacheCriteria, CacheInstruction instruction)
 {
     _acceptInstructions.Add(new AcceptInstruction(cacheCriteria, instruction));
     return(this);
 }
예제 #3
0
 public AcceptInstruction(Func <MemberInfo, bool> acceptCriteria, CacheInstruction instruction)
 {
     _acceptCriteria = acceptCriteria;
     _instruction    = instruction;
 }