# CachesFutures

# CachesFutures


```
public abstract class CachesFutures
```

<br />

*** ** * ** ***

A Java-friendly wrapper for the Caches class, providing `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` for asynchronous operations.

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/CachedContext>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures#create(com.google.mlkit.genai.prompt.CreateCachedContextRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/CreateCachedContextRequest request)` Creates a cached context that can be used in future `GenerateContentRequest`s. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Boolean.html>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures#delete(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html name)` Deletes the cached context with the given name. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures#from(com.google.mlkit.genai.prompt.GenerativeModel)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel generativeModel)` |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/CachedContext>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures#get(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html name)` Returns the cached context with the given name. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/CachedContext>>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures#list()()` Queries the cached contexts created by `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures#create(com.google.mlkit.genai.prompt.CreateCachedContextRequest)`. |

## Public methods

### create

```
public abstract @NonNull ListenableFuture<@NonNull CachedContext> create(@NonNull CreateCachedContextRequest request)
```

Creates a cached context that can be used in future `GenerateContentRequest`s.

### delete

```
public abstract @NonNull ListenableFuture<@NonNull Boolean> delete(@NonNull String name)
```

Deletes the cached context with the given name.

### from

```
public static final @NonNull CachesFutures from(@NonNull GenerativeModel generativeModel)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel generativeModel` | the `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel` instance that contains the Caches instance. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures` | a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures` created from the provided `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel` instance. |

### get

```
public abstract @NonNull ListenableFuture<CachedContext> get(@NonNull String name)
```

Returns the cached context with the given name.

### list

```
public abstract @NonNull ListenableFuture<@NonNull List<@NonNull CachedContext>> list()
```

Queries the cached contexts created by `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/CachesFutures#create(com.google.mlkit.genai.prompt.CreateCachedContextRequest)`.