Table of Contents

Struct Cacheable<TEntity, TId>

Namespace
Kook
Assembly
Kook.Net.Core.dll

Represents a cached entity.

public readonly struct Cacheable<TEntity, TId> where TEntity : IEntity<TId> where TId : IEquatable<TId>

Type Parameters

TEntity

The type of entity that is cached.

TId

The type of this entity's ID.

Inherited Members

Properties

HasValue

Gets whether this entity is cached.

public bool HasValue { get; }

Property Value

bool

Id

Gets the ID of this entity.

public TId Id { get; }

Property Value

TId

Value

Gets the entity if it could be pulled from cache.

public TEntity? Value { get; }

Property Value

TEntity

Remarks

This value is not guaranteed to be set; in cases where the entity cannot be pulled from cache, it is null.

Methods

DownloadAsync()

Downloads this entity to cache.

public Task<TEntity?> DownloadAsync()

Returns

Task<TEntity>

A task that represents the asynchronous download operation. The task result contains the downloaded entity.

Exceptions

HttpException

Thrown when used from a user account.

NullReferenceException

Thrown when the entity is deleted.

GetOrDownloadAsync()

Returns the cached entity if it exists; otherwise downloads it.

public Task<TEntity?> GetOrDownloadAsync()

Returns

Task<TEntity>

A task that represents the asynchronous operation that attempts to get the entity via cache or to download the entity. The task result contains the downloaded entity.

Exceptions

HttpException

Thrown when used from a user account.

NullReferenceException

Thrown when the entity is deleted and is not in cache.