# QueryRef.FetchPolicy


```
enum QueryRef.FetchPolicy : Enum
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||
| ↳ | [kotlin.Enum](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/index.html) ||
|   | ↳ | [com.google.firebase.dataconnect.QueryRef.FetchPolicy](https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy) |

*** ** * ** ***

The caching policy to use in `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef#execute()`.

## Summary

| ### Enum Values |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy#CACHE_ONLY` | Return the query result from the cache without any communication with the server. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy#PREFER_CACHE` | If the query has a cached result that has not expired, then return it without any communication with the server, just as `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy#CACHE_ONLY` would do. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy#SERVER_ONLY` | Unconditionally get the latest result from the server, even if there is a locally-cached result for the query. |

| ### Public functions |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy#valueOf(kotlin.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Returns the enum constant of this type with the specified name. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy#values()()` Returns an array containing the constants of this enum type, in the order they're declared. |

## Enum Values

### CACHE_ONLY

```
val QueryRef.FetchPolicy.CACHE_ONLY: QueryRef.FetchPolicy
```

Return the query result from the cache without any communication with the server. If there is no cached data for the query then return an empty/null result, just as the server would have returned in that case.

### PREFER_CACHE

```
val QueryRef.FetchPolicy.PREFER_CACHE: QueryRef.FetchPolicy
```

If the query has a cached result that has not expired, then return it without any communication with the server, just as `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy#CACHE_ONLY` would do. Otherwise, if there is no cached data for the query or the cached data has expired, then get the latest result from the server, just as `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/dataconnect/QueryRef.FetchPolicy#SERVER_ONLY` would do.

### SERVER_ONLY

```
val QueryRef.FetchPolicy.SERVER_ONLY: QueryRef.FetchPolicy
```

Unconditionally get the latest result from the server, even if there is a locally-cached result for the query. The local cache will be updated with the result, if successful.

## Public functions

### valueOf

```
fun valueOf(value: String): QueryRef.FetchPolicy
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

| Throws |
|---|---|
| `kotlin.IllegalArgumentException: kotlin.IllegalArgumentException` | if this enum type has no constant with the specified name |

### values

```
fun values(): Array<QueryRef.FetchPolicy>
```

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.