public override string Save(object data) { string id = Guid.NewGuid().ToString(); this.AcquireWriterLock(); try { StringCollection keys = new StringCollection(); foreach (string key in this._storeItems.Keys) { YZTempStorageItem item1 = this._storeItems[key]; if (item1.IsExpired(this._timeoutInMinutes)) { keys.Add(key); } } foreach (string key in keys) { this._storeItems.Remove(key); } this._storeItems.Add(id, new YZTempStorageItem(id, data)); } finally { this.ReleaseWriterLock(); } return(id); }
public override object Load(string id) { this.AcquireReaderLock(); try { YZTempStorageItem item = null; if (this._storeItems.TryGetValue(id, out item)) { return(item.Data); } else { return(null); } } finally { this.ReleaseLock(); } }