protected SpoolItem <TKey, T> GetSpoolItem(TKey key) { SpoolItem <TKey, T> store = null; if (DictInternal.TryGetValue(key, out store)) { if (!IsValid(store)) { SpoolItem <TKey, T> store1 = null; DictInternal.TryRemove(key, out store1); } } return(store); }
protected bool IsValid(SpoolItem <TKey, T> item) { return((ActualForMs <= 0) || (item.Updated.AddMilliseconds(ActualForMs) > DateTime.Now)); }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <returns></returns> public T SpoolGet(TKey key) { SpoolItem <TKey, T> store = GetSpoolItem(key); return(store?.Item); }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <returns>Old Item if was / null</returns> public T SpoolDelete(TKey key) { SpoolItem <TKey, T> outRet = null; return((DictInternal.TryRemove(key, out outRet)) ? outRet.Item : null); }