private void Increment(PerformanceLogger logger) { if (_persistence != null) { if (_persistence != null) { Dictionary<string, Counter> counters; if (_persistence.Contains("request-counters")) { counters = _persistence["request-counters"] as Dictionary<string, Counter>; } else { counters = new Dictionary<string, Counter>(); _persistence["request-counters"] = counters; } if (counters.ContainsKey(logger._name)) { counters[logger._name].Add(logger); } else { counters[logger._name] = new Counter() { TotalMilliseconds = logger._time, Count = 1, Stack = Environment.StackTrace }; } } } }
public void GetMany(List <GetReference> req) { if (_cache == null) { return; } using (var log = new PerformanceLogger("redis-get-many", _loggingPersistence)) { for (var i = 0; i < req.Count; i++) { var r = req[i]; if (r.ExpectSingleValue) { var val = _cache.Get(r.CacheKey) as ITableBacked; if (val == null) { req[i].Result = null; } else { req[i].Result = new ITableBacked[] { val }.ToList(); } } else { req[i].Result = _cache.Get(r.CacheKey) as List <ITableBacked>; } } } return; }
private void Increment(PerformanceLogger logger) { if (_persistence != null) { if (_persistence != null) { Dictionary <string, Counter> counters; if (_persistence.Contains("request-counters")) { counters = _persistence["request-counters"] as Dictionary <string, Counter>; } else { counters = new Dictionary <string, Counter>(); _persistence["request-counters"] = counters; } if (counters.ContainsKey(logger._name)) { counters[logger._name].Add(logger); } else { counters[logger._name] = new Counter() { TotalMilliseconds = logger._time, Count = 1, Stack = Environment.StackTrace }; } } } }
public void GetMany(List <GetReference> req) { if (_db == null) { return; } using (var log = new PerformanceLogger("redis-get-many", _loggingPersistence)) { var values = _db.StringGet( req.Select(x => (RedisKey)x.CacheKey) .ToArray() ); for (var i = 0; i < values.Length; i++) { if (req[i].ExpectSingleValue) { var val = DeserializeSingle(values[i]); if (val == null) { req[i].Result = null; } else { req[i].Result = new ITableBacked[] { val }.ToList(); } } else { req[i].Result = DeserializeList(values[i]); } } } return; }
public void Add(PerformanceLogger log) { Count++; TotalMilliseconds += log._time; Stack = Environment.StackTrace; }
public bool Set <T>(string cacheKey, T value) where T : class { if (_cache == null) { return(false); } using (var log = new PerformanceLogger("redis-set", _loggingPersistence)) { using (var log2 = new PerformanceLogger("redis-set|" + cacheKey, _loggingPersistence)) { _cache.Set(cacheKey, value, new CacheItemPolicy()); return(true); } } }
public T Get <T>(string cacheKey) where T : class { if (_cache == null) { return(null); } using (var log = new PerformanceLogger("redis-get", _loggingPersistence)) { using (var log2 = new PerformanceLogger("redis-get|" + cacheKey, _loggingPersistence)) { return(_cache.Get(cacheKey) as T); } } }
public bool Set <T>(string cacheKey, T value) where T : class { if (_db == null) { return(false); } using (var log = new PerformanceLogger("redis-set", _loggingPersistence)) { using (var log2 = new PerformanceLogger("redis-set|" + cacheKey, _loggingPersistence)) { byte[] buffer = Serialize(value); _db.StringSet(cacheKey, buffer); return(true); } } }
public T Get <T>(string cacheKey) where T : class { if (_db == null) { return(null); } using (var log = new PerformanceLogger("redis-get", _loggingPersistence)) { using (var log2 = new PerformanceLogger("redis-get|" + cacheKey, _loggingPersistence)) { byte[] buffer = _db.StringGet(cacheKey); return(Deserialize <T>(buffer)); } } }
public async Task <List <T> > GetManyAsync <T>(List <string> cacheKeys) where T : class { if (_db == null) { return(null); } using (var log = new PerformanceLogger("redis-get-many", _loggingPersistence)) { var values = await _db.StringGetAsync( cacheKeys .Select(x => (RedisKey)x) .ToArray() ); return(values.Select(x => Deserialize <T>(x)).ToList()); } }
public void Add(PerformanceLogger log) { Count++; TotalMilliseconds += log._time; Stack = Environment.StackTrace; }