Struct Cacheable<TEntity, TId>
Represents a cached entity.
Namespace: Discord
Assembly: Discord.Net.Core.dll
Syntax
public struct Cacheable<TEntity, TId>
where TEntity : IEntity<TId> where TId : IEquatable<TId>
Type Parameters
Name | Description |
---|---|
TEntity | The type of entity that is cached. |
TId | The type of this entity's ID. |
Properties
| Improve this Doc View SourceHasValue
Gets whether this entity is cached.
Declaration
public readonly bool HasValue { get; }
Property Value
Type | Description |
---|---|
Boolean |
Id
Gets the ID of this entity.
Declaration
public readonly TId Id { get; }
Property Value
Type | Description |
---|---|
TId |
Value
Gets the entity if it could be pulled from cache.
Declaration
public readonly TEntity Value { get; }
Property Value
Type | Description |
---|---|
TEntity |
Remarks
This value is not guaranteed to be set; in cases where the entity cannot be pulled from cache, it is
null
.
Methods
| Improve this Doc View SourceDownloadAsync()
Downloads this entity to cache.
Declaration
public async Task<TEntity> DownloadAsync()
Returns
Type | Description |
---|---|
Task<TEntity> | A task that represents the asynchronous download operation. The task result contains the downloaded entity. |
Exceptions
Type | Condition |
---|---|
HttpException | Thrown when used from a user account. |
GetOrDownloadAsync()
Returns the cached entity if it exists; otherwise downloads it.
Declaration
public async Task<TEntity> GetOrDownloadAsync()
Returns
Type | Description |
---|---|
Task<TEntity> | A task that represents the asynchronous operation that attempts to get the message via cache or to download the message. The task result contains the downloaded entity. |
Exceptions
Type | Condition |
---|---|
HttpException | Thrown when used from a user account. |