public enum

CachePolicy

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.kinvey.java.cache.CachePolicy

Class Overview

Set the caching policy on AppData to getdifferent desired behavior for you app.

See Also
  • {@link com.kinvey.java.AppData#setCache(Cache, CachePolicy)} for more details.

Summary

Enum Values
CachePolicy  BOTH  This policy will first retrieve an element from the cache, and then it will attempt to execute the request on line. 
CachePolicy  CACHEFIRST  This policy will first attempt to retrieve data from the cache. 
CachePolicy  CACHEFIRST_NOREFRESH  This policy will first attempt to retrieve data from the cache. 
CachePolicy  CACHEONLY  This policy will only retrieve data from the cache, and will not use any network connection. 
CachePolicy  NETWORKFIRST  This policy will execute the request on the network, and will store the result in the cache. 
CachePolicy  NOCACHE  This policy will not use any caching, and will execute every request online. 
Public Methods
abstract <T> T execute(AbstractKinveyCachedClientRequest<T> cachedRequest)
static CachePolicy valueOf(String name)
final static CachePolicy[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final CachePolicy BOTH

This policy will first retrieve an element from the cache, and then it will attempt to execute the request on line. This caching policy will make two calls to the KinveyClientCallback, either onSuccess or onFailure for both executing on the cache as well as executing online.

Use this policy if you want more responsiveness without sacrificing the consistency of data with your backend.

public static final CachePolicy CACHEFIRST

This policy will first attempt to retrieve data from the cache. If the data has been cached, it will be returned. If the data does not exist in the cache, the data will be retrieved from Kinvey's Backend and the cache will be updated.

Use this policy if your application can display data that doesn't change very often but you still want local updates.

public static final CachePolicy CACHEFIRST_NOREFRESH

This policy will first attempt to retrieve data from the cache. If the data has been cached, it will be returned. If the data does not exist in the cache, the data will be retrieved from Kinvey's Backend but the cache will not be updated with the new results.

Use this policy if you want to set default results, however if a request is made that cannot return these defaults a live request will be made (without modifying those default values)

public static final CachePolicy CACHEONLY

This policy will only retrieve data from the cache, and will not use any network connection.

Use this policy in combination with another policy, to allow for quick response times without requiring a network connection for specific operations.

public static final CachePolicy NETWORKFIRST

This policy will execute the request on the network, and will store the result in the cache. If the online execution fails, the results will be pulled from the cache.

Use this policy if you application wants the latest data but you still want responsiveness if a connection is lost

public static final CachePolicy NOCACHE

This policy will not use any caching, and will execute every request online.

Use this policy if your application is dependant on data that is shared between multiple users and always needs to be up to date.

Public Methods

public abstract T execute (AbstractKinveyCachedClientRequest<T> cachedRequest)

Throws
IOException

public static CachePolicy valueOf (String name)

public static final CachePolicy[] values ()