public bool ContainsKey(string strKey) { bool blnContainsKey = false; if (Records.ContainsKey(strKey) == true) { CacheRecord objRecord = Records[strKey]; if (objRecord != null) { if (objRecord.HasExpired == true) { lock (_objLockObject) { if (Records.ContainsKey(strKey) == true) { Records.Remove(strKey); } } } else { blnContainsKey = true; } } } return(blnContainsKey); }
public TValueType GetValue <TValueType>(string strKey, TValueType objDefault) { TValueType objValue = objDefault; if (Records.ContainsKey(strKey) == true) { CacheRecord objRecord = Records[strKey]; if (objRecord != null) { if (objRecord.HasExpired == true) { lock (_objLockObject) { if (Records.ContainsKey(strKey) == true) { Records.Remove(strKey); } } } else { objValue = (TValueType)objRecord.Value; } } } return(objValue); }
public void SetValue(string strKey, object objValue, DateTime objExpirationDate) { lock (_objLockObject) { if (Records.ContainsKey(strKey) == true) { Records.Remove(strKey); } CacheRecord objRecord = new CacheRecord(strKey, objValue, objExpirationDate); Records.Add(strKey, objRecord); } }