| Enum Constant and Description |
|---|
CACHE_REMOTE
先使用缓存,不管是否存在,仍然请求网络,会回调两次
|
CACHE_REMOTE_DISTINCT
先使用缓存,不管是否存在,仍然请求网络,会先把缓存回调给你,
等网络请求回来发现数据是一样的就不会再返回,否则再返回
(这样做的目的是防止数据是一样的你也需要刷新界面)
|
DEFAULT
完全按照HTTP协议的默认缓存规则,走OKhttp的Cache缓存
|
FIRST_CACHE
先加载缓存,缓存没有再去请求网络
|
FIRST_REMOTE
先请求网络,请求网络失败后再加载缓存
|
NO_CACHE
不使用缓存,该模式下,mCacheKey,cacheMaxAge 参数均无效
|
ONLY_CACHE
只读取缓存
|
ONLY_REMOTE
仅加载网络,但数据依然会被缓存
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getClassName() |
static CacheMode |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static CacheMode[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final CacheMode NO_CACHE
public static final CacheMode DEFAULT
public static final CacheMode FIRST_REMOTE
public static final CacheMode FIRST_CACHE
public static final CacheMode ONLY_REMOTE
public static final CacheMode ONLY_CACHE
public static final CacheMode CACHE_REMOTE
public static final CacheMode CACHE_REMOTE_DISTINCT
public static CacheMode[] values()
for (CacheMode c : CacheMode.values()) System.out.println(c);
public static CacheMode valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String getClassName()