Table of Contents

Class CachingClient

Namespace
GenerativeAI.Clients
Assembly
GenerativeAI.dll

A client for interacting with the Gemini API Caching endpoint.

public class CachingClient : BaseClient
Inheritance
CachingClient
Inherited Members
Extension Methods

Constructors

CachingClient(IPlatformAdapter, HttpClient?, ILogger?)

Provides methods to interact with caching resources for generative AI models.

public CachingClient(IPlatformAdapter platform, HttpClient? httpClient = null, ILogger? logger = null)

Parameters

platform IPlatformAdapter
httpClient HttpClient
logger ILogger

Remarks

This client manages and performs operations related to cached contents, such as creating, retrieving, or listing cached resources.

See Also

Methods

CreateCachedContentAsync(CachedContent, CancellationToken)

Asynchronously creates a new cached content resource.

public Task<CachedContent> CreateCachedContentAsync(CachedContent cachedContent, CancellationToken cancellationToken = default)

Parameters

cachedContent CachedContent

The cached content to be created.

cancellationToken CancellationToken

Optional token to monitor for cancellation requests.

Returns

Task<CachedContent>

The created cached content resource.

See Also

DeleteCachedContentAsync(string, CancellationToken)

Deletes a cached content resource asynchronously.

public Task DeleteCachedContentAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string

The name of the cached content resource to delete.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task

A task representing the asynchronous delete operation.

See Also

GetCachedContentAsync(string, CancellationToken)

Retrieves a specific cached content resource asynchronously.

public Task<CachedContent?> GetCachedContentAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string

The resource name of the cached content to retrieve.

cancellationToken CancellationToken

Optional cancellation token to cancel the operation.

Returns

Task<CachedContent>

An instance of CachedContent representing the retrieved resource, or null if not found.

See Also

ListCachedContentsAsync(int?, string?, CancellationToken)

Asynchronously retrieves a list of CachedContent resources.

public Task<ListCachedContentsResponse> ListCachedContentsAsync(int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)

Parameters

pageSize int?

Optional parameter to specify the maximum number of CachedContent resources to return.

pageToken string

Optional parameter for a pagination token, used to retrieve the next page of results.

cancellationToken CancellationToken

Optional parameter to propagate notification that the operation should be canceled.

Returns

Task<ListCachedContentsResponse>

A task representing the asynchronous operation, containing a ListCachedContentsResponse with the list of fetched CachedContent resources.

See Also

UpdateCachedContentAsync(string, CachedContent, string?, CancellationToken)

Updates an existing cached content resource by modifying supported fields, such as expiration time.

public Task<CachedContent?> UpdateCachedContentAsync(string cacheName, CachedContent cachedContent, string? updateMask = null, CancellationToken cancellationToken = default)

Parameters

cacheName string

The name of the cache containing the cached content to update.

cachedContent CachedContent

The cached content resource with updated values.

updateMask string

Optional. Specifies which fields in the cache content resource to update.

cancellationToken CancellationToken

Optional. A token for canceling the asynchronous operation.

Returns

Task<CachedContent>

A task representing the asynchronous operation, containing the updated cached content resource.

See Also

See Also