public StatRecord SetTail(string tailKey, long cash, long count) { var record = new StatRecord {Count = count, AggCash = cash}; return MemoryCache.Set<StatRecord>(tailKey, record, TailOptions); }
public async virtual Task<StatRecord> IncrementBucket(string bucketKey, long cash, long count) { var bucketHash = Math.Abs(bucketKey.Substring(0, 17).GetHashCode()); StatCollection collection= await GetCollection(bucketHash); if (collection == null) { throw new InvalidOperationException("Evicted ?"); } StatRecord record; lock (collection) { if (!collection.Records.TryGetValue(bucketHash, out record)) { record = new StatRecord(collection) { AggCash = cash, Count = count, }; collection.Records.Add(bucketHash, record); } else { record.AggCash += cash; record.Count += count; if (record.Count > 1000000) { record.AggCash /= 1000; record.Count /= 1000; } } collection.IsDirty = true; } return record; }
public NavigatorResult(StatRecord record) { Record = record; }