public object Get(string pieId) { if (_cachedObjectGetters.ContainsKey(pieId)) { var storedObject = _cachedObjectGetters[pieId]; if (storedObject != null) { return storedObject.Value; } else return null; } else { var storedObject = DataStore[pieId] ?? new StoredObject(null, Guid.NewGuid().ToString()); object value = null; if (storedObject.SerializedObjectValue != null) { value = JsonConvert.DeserializeObject(storedObject.SerializedObjectValue, DataStore.SerializerSettings); value.PieId(pieId); } var cachedObject = new CachedObject(value, storedObject.ETag); _cachedObjectGetters[pieId] = cachedObject; return cachedObject.Value; } }
public void Store(object o, string pieId) { if (_cachedObjectGetters.ContainsKey(pieId)) { var currentCachedObject = _cachedObjectGetters[pieId]; _cachedObjectGetters[pieId] = new CachedObject(o, currentCachedObject.ETag); } else { _cachedObjectGetters[pieId] = new CachedObject(o, Guid.NewGuid().ToString()); } }
public void Remove(string id) { var current = Get(id); var currentCachedObject = _cachedObjectGetters[id]; _cachedObjectGetters[id] = new CachedObject(null, currentCachedObject.ETag); }