# CachesFutures

# CachesFutures


```
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 companion functions |
|---|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures#from(com.google.mlkit.genai.prompt.GenerativeModel)(generativeModel: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel)` |

| ### Public functions |
|---|---|
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/CachedContext>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures#create(com.google.mlkit.genai.prompt.CreateCachedContextRequest)(request: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/CreateCachedContextRequest)` Creates a cached context that can be used in future `GenerateContentRequest`s. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures#delete(kotlin.String)(name: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Deletes the cached context with the given name. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/CachedContext?>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures#get(kotlin.String)(name: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Returns the cached context with the given name. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/CachedContext>>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures#list()()` Queries the cached contexts created by `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures#create(com.google.mlkit.genai.prompt.CreateCachedContextRequest)`. |

## Public companion functions

### from

```
fun from(generativeModel: GenerativeModel): CachesFutures
```

| Parameters |
|---|---|
| `generativeModel: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` | the `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` instance that contains the Caches instance. |

| Returns |
|---|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures` | a `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/CachesFutures` created from the provided `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` instance. |

## Public functions

### create

```
abstract fun create(request: CreateCachedContextRequest): ListenableFuture<CachedContext>
```

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

### delete

```
abstract fun delete(name: String): ListenableFuture<Boolean>
```

Deletes the cached context with the given name.

### get

```
abstract fun get(name: String): ListenableFuture<CachedContext?>
```

Returns the cached context with the given name.

### list

```
abstract fun list(): ListenableFuture<List<CachedContext>>
```

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