| 1234567891011121314151617181920212223242526272829303132333435363738 |
- namespace Quadarax.Foundation.Common.Cache
- {
- public abstract class Cache<TKey, TValue>
- {
- public bool Enabled { get; set; }
- public TValue this[TKey key]
- {
- get
- {
- if (!this.Enabled)
- return default(TValue);
- return this.GetValue(key);
- }
- set
- {
- if (!this.Enabled)
- return;
- this.SetValue(key, value);
- }
- }
- public bool Remove(TKey key)
- {
- if (!this.Enabled)
- return false;
- return this.RemoveByKey(key);
- }
- public abstract bool Invalidate(TKey key);
- protected abstract TValue GetValue(TKey key);
- protected abstract void SetValue(TKey key, TValue value);
- protected abstract bool RemoveByKey(TKey key);
- }
- }
|