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; })); }
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; })); }
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; })); }