Class MemoryCache<TKey, TItem>
Generic implementation of
Inheritance
System.Object
MemoryCache<TKey, TItem>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Fusee.Base.Core
Assembly: Fusee.Base.Core.dll
Syntax
public class MemoryCache<TKey, TItem>
Type Parameters
Name | Description |
---|---|
TKey | |
TItem |
Constructors
MemoryCache()
Creates a new instance and initializes the internal
Declaration
public MemoryCache()
Fields
ExpirationScanFrequency
Time between successive scans for expired items.
Declaration
public int ExpirationScanFrequency
Field Value
Type | Description |
---|---|
System.Int32 |
HandleEvictedItem
Method that is called when an item was evicted from the cache.
Declaration
public PostEvictionDelegate HandleEvictedItem
Field Value
Type | Description |
---|---|
PostEvictionDelegate |
SlidingExpiration
Sets how long a cache entry can be inactive (not accessed) before it will be removed.
Declaration
public int SlidingExpiration
Field Value
Type | Description |
---|---|
System.Int32 |
Methods
Add(TKey, TItem)
Adds the given item to the cache. Will not check if the item is already in the cache!
Declaration
public void Add(TKey key, TItem cacheEntry)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the cache item. |
TItem | cacheEntry | The cache item. |
AddOrUpdate(TKey, TItem)
If the item isn't in the cache, add it, otherwise override the value in the cache.
Declaration
public void AddOrUpdate(TKey key, TItem cacheEntry)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the cache item. |
TItem | cacheEntry | The cache item. |
TryGetValue(TKey, out TItem)
Tries to get an item from the cache.
Declaration
public bool TryGetValue(TKey key, out TItem item)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the cached item. |
TItem | item | The received cache item. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was in the cache, false otherwise. |