Class ClassObjectCacheBase<TKey, TValue>
An abstract base class for implementing IClassObjectCache<TKey, TValue>.
Implements
Inherited Members
Namespace: Microsoft.XboxStudios.GameStateTracker.Cache
Assembly: GameStateTracker.Core.dll
Syntax
public abstract class ClassObjectCacheBase<TKey, TValue> : ObjectCacheBase<TKey, TValue>, IClassObjectCache<TKey, TValue>, IObjectCache<TKey, TValue>, ICollection<TValue>, IEnumerable<TValue>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable where TKey : IEquatable<TKey> where TValue : notnull
Type Parameters
Name | Description |
---|---|
TKey | The info type. |
TValue | The object type. |
Constructors
View SourceClassObjectCacheBase(IReadOnlyCollection<TValue>?)
Initializes a new instance of the ClassObjectCacheBase<TKey, TValue> class.
Declaration
protected ClassObjectCacheBase(IReadOnlyCollection<TValue>? existing = null)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<TValue> | existing | The objects to initialize the cache with. |
Methods
View SourceClearClass(TKey)
Removes all matching objects from the cache.
Declaration
public void ClearClass(TKey classKey)
Parameters
Type | Name | Description |
---|---|---|
TKey | classKey | The object info. |
ClearClassAges(TKey)
Removes the age of objects with the given class from the cache.
Declaration
protected void ClearClassAges(TKey classKey)
Parameters
Type | Name | Description |
---|---|---|
TKey | classKey | The class info. |
GetClassAge(TKey)
Gets the age of a set of objects in the cache.
Declaration
public TimeSpan? GetClassAge(TKey classKey)
Parameters
Type | Name | Description |
---|---|---|
TKey | classKey | The objects to search for. |
Returns
Type | Description |
---|---|
TimeSpan? | The time since the objects were last refreshed. |
GetClassAge(TKey, DateTime)
Gets the age of a set of objects in the cache.
Declaration
public TimeSpan? GetClassAge(TKey classKey, DateTime now)
Parameters
Type | Name | Description |
---|---|---|
TKey | classKey | The objects to search for. |
DateTime | now | The current time to compare to. |
Returns
Type | Description |
---|---|
TimeSpan? | The time since the objects were last refreshed. |
GetObjectAge(TKey, DateTime)
Gets the age of an object in the cache.
Declaration
public override TimeSpan? GetObjectAge(TKey info, DateTime now)
Parameters
Type | Name | Description |
---|---|---|
TKey | info | The object info. |
DateTime | now | The current time to compare to. |
Returns
Type | Description |
---|---|
TimeSpan? | The time since the object was last refreshed. |
Overrides
View SourceRefreshClass(TKey)
Updates the age of all matching objects in the cache.
Declaration
public void RefreshClass(TKey classKey)
Parameters
Type | Name | Description |
---|---|---|
TKey | classKey | The objects to search for. |
RefreshClass(TKey, DateTime)
Updates the age of all matching objects in the cache.
Declaration
public void RefreshClass(TKey classKey, DateTime now)
Parameters
Type | Name | Description |
---|---|---|
TKey | classKey | The objects to search for. |
DateTime | now | The current time to set. |
Remove(TKey)
Removes an object from the cache.
Declaration
public override bool Remove(TKey item)
Parameters
Type | Name | Description |
---|---|---|
TKey | item | The object info. |
Returns
Type | Description |
---|---|
bool | True if the object was removed. |
Overrides
View SourceToClassKey(in TKey)
Converts an object's info to its class info.
Declaration
protected abstract TKey ToClassKey(in TKey info)
Parameters
Type | Name | Description |
---|---|---|
TKey | info | The object info. |
Returns
Type | Description |
---|---|
TKey | The class info. |