com.parse

## Enum ParseQuery.CachePolicy

- java.lang.Object
- - java.lang.Enum<ParseQuery.CachePolicy>
  - - com.parse.ParseQuery.CachePolicy

All Implemented Interfaces:
  Serializable, Comparable<ParseQuery.CachePolicy>

Enclosing class:
  ParseQuery<T extends ParseObject>

    public static enum ParseQuery.CachePolicy
    extends Enum<ParseQuery.CachePolicy>

`CachePolicy` specifies different caching policies that could be used with `ParseQuery`.

This lets you show data when the user's device is offline, or when the app has just started and network requests have not yet had time to complete. Parse takes care of automatically flushing the cache when it takes up too much space.

Note: Cache policy can only be set when Local Datastore is not enabled.

See Also:
  `ParseQuery`

### Enum Constant Summary

Enum Constants
Enum Constant and Description
`CACHE_ELSE_NETWORK` The query first tries to load from the cache, but if that fails, it loads results from the network.
`CACHE_ONLY` The query only loads from the cache, ignoring the network.
`CACHE_THEN_NETWORK` The query first loads from the cache, then loads from the network.
`IGNORE_CACHE` The query does not load from the cache or save results to the cache.
`NETWORK_ELSE_CACHE` The query first tries to load from the network, but if that fails, it loads results from the cache.
`NETWORK_ONLY` The query does not load from the cache, but it will save results to the cache.

### Method Summary

Methods
`static ParseQuery.CachePolicy` `valueOf(String name)` Returns the enum constant of this type with the specified name.
`static ParseQuery.CachePolicy[]` `values()` Returns an array containing the constants of this enum type, in the order they are declared.

### Methods inherited from class java.lang.Enum

`clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Enum Constant Detail

#### IGNORE_CACHE

    public static final ParseQuery.CachePolicy IGNORE_CACHE

The query does not load from the cache or save results to the cache.

This is the default cache policy.

#### CACHE_ONLY

    public static final ParseQuery.CachePolicy CACHE_ONLY

The query only loads from the cache, ignoring the network.

If there are no cached results, this causes a `ParseException.CACHE_MISS`.

#### NETWORK_ONLY

    public static final ParseQuery.CachePolicy NETWORK_ONLY

The query does not load from the cache, but it will save results to the cache.

#### CACHE_ELSE_NETWORK

    public static final ParseQuery.CachePolicy CACHE_ELSE_NETWORK

The query first tries to load from the cache, but if that fails, it loads results from the network.

If there are no cached results, this causes a `ParseException.CACHE_MISS`.

#### NETWORK_ELSE_CACHE

    public static final ParseQuery.CachePolicy NETWORK_ELSE_CACHE

The query first tries to load from the network, but if that fails, it loads results from the cache.

If there are no cached results, this causes a `ParseException.CACHE_MISS`.

#### CACHE_THEN_NETWORK

    public static final ParseQuery.CachePolicy CACHE_THEN_NETWORK

The query first loads from the cache, then loads from the network. The callback will be called twice - first with the cached results, then with the network results. Since it returns two results at different times, this cache policy cannot be used with synchronous or task methods.

### Method Detail

#### values

    public static ParseQuery.CachePolicy[] values()

Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

    for (ParseQuery.CachePolicy c : ParseQuery.CachePolicy.values())
        System.out.println(c);

Returns:
  an array containing the constants of this enum type, in the order they are declared

#### valueOf

    public static ParseQuery.CachePolicy valueOf(String name)

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.)

Parameters:
  `name` - the name of the enum constant to be returned.
Returns:
  the enum constant with the specified name
Throws:
  `IllegalArgumentException` - if this enum type has no constant with the specified name
  `NullPointerException` - if the argument is null