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
platformIPlatformAdapterhttpClientHttpClientloggerILogger
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
cachedContentCachedContentThe cached content to be created.
cancellationTokenCancellationTokenOptional 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
namestringThe name of the cached content resource to delete.
cancellationTokenCancellationTokenA 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
namestringThe resource name of the cached content to retrieve.
cancellationTokenCancellationTokenOptional 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
pageSizeint?Optional parameter to specify the maximum number of CachedContent resources to return.
pageTokenstringOptional parameter for a pagination token, used to retrieve the next page of results.
cancellationTokenCancellationTokenOptional 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
cacheNamestringThe name of the cache containing the cached content to update.
cachedContentCachedContentThe cached content resource with updated values.
updateMaskstringOptional. Specifies which fields in the cache content resource to update.
cancellationTokenCancellationTokenOptional. A token for canceling the asynchronous operation.
Returns
- Task<CachedContent>
A task representing the asynchronous operation, containing the updated cached content resource.
- See Also