예제 #1
0
 public virtual T GetByIdOrDefault(object id)
 {
     return(Cache.GetOrCache(GetIdCacheKey(id), context =>
     {
         var item = Db.GetByIdOrDefault <T>(id);
         if (item != null)
         {
             context.InvalidateOn(TriggerFrom.Id <T>(id));
         }
         return item;
     }));
 }
예제 #2
0
 public User GetByUsername(string username)
 {
     return(Cache.GetOrCache(CacheKeys.Users.ByUsername(username), context =>
     {
         var item = Db.SingleOrDefault <User>(new { username });
         if (item != null)
         {
             context.InvalidateOn(TriggerFrom.Id <User>(item.Id));
         }
         return item;
     }));
 }
예제 #3
0
 public object GetByName(string name)
 {
     return(Cache.GetOrCache(CacheKeys.Objects.ByName(name), context =>
     {
         dynamic item = new ExpandoObject();
         item.Id = 2;
         item.Name = "somename";
         if (item != null)
         {
             context.InvalidateOn(TriggerFrom.Id <object>(item.Id));
         }
         return item;
     }));
 }