public virtual T Al <T>(string key) { //little performance workaround here: //we use "PerRequestCacheManager" to cache a loaded object in memory for the current HTTP request. //this way we won't connect to Redis server 500 times per HTTP request (e.g. each time to load a locale or setting) if (_perRequestCacheManager.Ayarlandı(key)) { return(_perRequestCacheManager.Al <T>(key)); } var rValue = _db.StringGet(key); if (!rValue.HasValue) { return(default(T)); } var result = Deserialize <T>(rValue); _perRequestCacheManager.Ayarla(key, result, 0); return(result); }
public static T Al <T>(this IÖnbellekYönetici önbellekYönetici, string key, int önbellekZamanı, Func <T> kazanım) { if (önbellekYönetici.Ayarlandı(key)) { return(önbellekYönetici.Al <T>(key)); } var sonuç = kazanım(); if (önbellekZamanı > 0) { önbellekYönetici.Ayarla(key, sonuç, önbellekZamanı); } return(sonuç); }