Table of Contents

Struct Cacheable<TCachedEntity, TDownloadableEntity, TRelationship, TId>

Namespace
Kook
Assembly
Kook.Net.Core.dll

Represents a cached entity that can be downloaded.

public readonly struct Cacheable<TCachedEntity, TDownloadableEntity, TRelationship, TId> where TCachedEntity : IEntity<TId>, TRelationship where TDownloadableEntity : IEntity<TId>, TRelationship where TId : IEquatable<TId>

Type Parameters

TCachedEntity

The type of entity that is cached.

TDownloadableEntity

The type of entity that can be downloaded.

TRelationship

The common type of TCachedEntity and TDownloadableEntity.

TId

The type of the corresponding 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 TCachedEntity? Value { get; }

Property Value

TCachedEntity

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.

public Task<TDownloadableEntity?> DownloadAsync()

Returns

Task<TDownloadableEntity>

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<TRelationship?> GetOrDownloadAsync()

Returns

Task<TRelationship>

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.