public async void SetState(string calculatorID, State state) { if (connection == null) { return; } // Being asynchronous, the caller can move on without waiting for the store operation to complete. // Put another way, the store operation is a fire-and-forget kind of operation. IDatabase database = connection.GetDatabase(); await database.StringSetAsync(calculatorID, state.SerializeToString()); DateTime timeStamp = DateTime.Now; await database.StringSetAsync(calculatorID + "_timeStamp", timeStamp.ToString()); if (stateCacheMap.ContainsKey(calculatorID)) { stateCacheMap.Remove(calculatorID); } StateCacheEntry cacheEntry = new StateCacheEntry(); cacheEntry.timeStamp = timeStamp; cacheEntry.state = state; stateCacheMap.Add(calculatorID, cacheEntry); }
private void CacheAdd(TStateId id, State ref_) { var newState = ref_; StateCacheEntry entry; if (!m_stateCache.TryGetValue(newState.StateId, out entry)) { entry = new StateCacheEntry(); m_stateCache.Add(newState.StateId, entry); } entry.ref_ = newState; entry.lastTouch = DateTime.Now; ++entry.refCount; }