Class WolfClientCache
Utility grouping common entity caches together.
Inheritance
Namespace: TehGM.Wolfringo.Caching.Internal
Assembly: Wolfringo.Core.dll
Syntax
public class WolfClientCache : IWolfClientCache, IWolfClientCacheAccessor, IDisposable
Remarks
This utility contains caches for entities that Wolf client is caching.
Each cache can be separately enabled or disabled.
Constructors
| Improve this Doc View SourceWolfClientCache(ILogger)
Creates new container and contained caches with all caches enabled.
Declaration
public WolfClientCache(ILogger log = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Extensions.Logging.ILogger | log | Logger that this cache can log to. If null, logging will be disabled. |
Remarks
All caches will be enabled by default.
WolfClientCache(WolfCacheOptions, ILogger)
Creates new container and contained caches.
Declaration
public WolfClientCache(WolfCacheOptions options, ILogger log = null)
Parameters
| Type | Name | Description |
|---|---|---|
| WolfCacheOptions | options | Options specifying which caches should be enabled. |
| Microsoft.Extensions.Logging.ILogger | log | Logger that this cache can log to. If null, logging will be disabled. |
WolfClientCache(WolfCacheOptions, ILogger<WolfClientCache>)
Creates new container and contained caches.
Declaration
public WolfClientCache(WolfCacheOptions options, ILogger<WolfClientCache> log)
Parameters
| Type | Name | Description |
|---|---|---|
| WolfCacheOptions | options | Options specifying which caches should be enabled. |
| Microsoft.Extensions.Logging.ILogger<WolfClientCache> | log | Logger that this cache can log to. If null, logging will be disabled. |
Properties
| Improve this Doc View SourceAchievementsCache
Achievements cache.
Declaration
protected IWolfCachedEntityCollection<WolfLanguage, WolfAchievement> AchievementsCache { get; }
Property Value
| Type | Description |
|---|---|
| IWolfCachedEntityCollection<WolfLanguage, WolfAchievement> |
CharmsCache
Charms cache.
Declaration
protected IWolfCachedEntityCollection<WolfCharm> CharmsCache { get; }
Property Value
| Type | Description |
|---|---|
| IWolfCachedEntityCollection<WolfCharm> |
GroupsCache
Groups cache.
Declaration
protected IWolfCachedEntityCollection<WolfGroup> GroupsCache { get; }
Property Value
| Type | Description |
|---|---|
| IWolfCachedEntityCollection<WolfGroup> |
IsAchievementsCachingEnabled
Whether caching of WolfAchievement is enabled.
Declaration
public bool IsAchievementsCachingEnabled { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsCharmsCachingEnabled
Whether caching of WolfCharm is enabled.
Declaration
public bool IsCharmsCachingEnabled { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsGroupsCachingEnabled
Whether caching of WolfGroup is enabled.
Declaration
public bool IsGroupsCachingEnabled { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsUsersCachingEnabled
Whether caching of WolfUser is enabled.
Declaration
public bool IsUsersCachingEnabled { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Log
A logger for logging messages.
Declaration
protected ILogger Log { get; }
Property Value
| Type | Description |
|---|---|
| Microsoft.Extensions.Logging.ILogger |
UsersCache
Users cache.
Declaration
protected IWolfCachedEntityCollection<WolfUser> UsersCache { get; }
Property Value
| Type | Description |
|---|---|
| IWolfCachedEntityCollection<WolfUser> |
Methods
| Improve this Doc View SourceClear()
Clears all caches.
Declaration
public virtual void Clear()
GetCachedAchievement(WolfLanguage, UInt32)
Get achievement from cache.
Declaration
public WolfAchievement GetCachedAchievement(WolfLanguage language, uint id)
Parameters
| Type | Name | Description |
|---|---|---|
| WolfLanguage | language | Language of achievement's translations. |
| System.UInt32 | id | ID of the achievement. |
Returns
| Type | Description |
|---|---|
| WolfAchievement | Cached achievement if found in requested language; otherwise null. |
GetCachedCharm(UInt32)
Get charm from cache.
Declaration
public WolfCharm GetCachedCharm(uint id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | id | ID of the charm. |
Returns
| Type | Description |
|---|---|
| WolfCharm | Cached charm if found; otherwise null. |
GetCachedGroup(String)
Get group from cache.
Declaration
public WolfGroup GetCachedGroup(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the group. |
Returns
| Type | Description |
|---|---|
| WolfGroup | Cached group if found; otherwise null. |
GetCachedGroup(UInt32)
Get group from cache.
Declaration
public WolfGroup GetCachedGroup(uint id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | id | ID of the group. |
Returns
| Type | Description |
|---|---|
| WolfGroup | Cached group if found; otherwise null. |
GetCachedUser(UInt32)
Get user from cache.
Declaration
public WolfUser GetCachedUser(uint id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | id | ID of the user. |
Returns
| Type | Description |
|---|---|
| WolfUser | Cached user if found; otherwise null. |
LogWarning(String, Object[])
Logs message with Warning level, and returns true.
Declaration
protected bool LogWarning(string message, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | message | Log message template. |
| System.Object[] | args | Structured log message arguments. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True. |
Remarks
Designed to use with catch (Exception) when pattern. Preserves log scope for logged message.
OnConnectingAsync(IWolfClient, CancellationToken)
Invoked when client is about to connect to the server.
Declaration
public virtual Task OnConnectingAsync(IWolfClient client, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| IWolfClient | client | WOLF client that is connecting to the server. |
| System.Threading.CancellationToken | cancellationToken | Cancellation token that can be used for Task cancellation. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
OnDisconnected(IWolfClient, SocketClosedEventArgs)
Invoked when the client has disconnected from the server.
Declaration
public virtual void OnDisconnected(IWolfClient client, SocketClosedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| IWolfClient | client | WOLF client that has disconnected from the server. |
| SocketClosedEventArgs | e | Event args raised when connection was closed. |
OnMessageReceivedAsync(IWolfClient, IWolfMessage, SerializedMessageData, CancellationToken)
Handle message received from the server.
Declaration
public virtual async Task OnMessageReceivedAsync(IWolfClient client, IWolfMessage message, SerializedMessageData rawMessage, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| IWolfClient | client | WOLF client that received the message. |
| IWolfMessage | message | Received message. |
| SerializedMessageData | rawMessage | Raw received message. |
| System.Threading.CancellationToken | cancellationToken | Cancellation token that can be used for Task cancellation. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
OnMessageSentAsync(IWolfClient, IWolfMessage, IWolfResponse, SerializedMessageData, CancellationToken)
Handle message sent by the client, and the server's response.
Declaration
public virtual Task OnMessageSentAsync(IWolfClient client, IWolfMessage message, IWolfResponse response, SerializedMessageData rawResponse, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| IWolfClient | client | WOLF client that sent the message. |
| IWolfMessage | message | Sent message. |
| IWolfResponse | response | Response received. |
| SerializedMessageData | rawResponse | Raw response data. |
| System.Threading.CancellationToken | cancellationToken | Cancellation token that can be used for Task cancellation. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Explicit Interface Implementations
| Improve this Doc View SourceIDisposable.Dispose()
Declaration
void IDisposable.Dispose()