java - okhttp3.3 框架中,如何设置cache?
大家讲道理
大家讲道理 2017-04-17 18:01:41
0
2
275

在okhttp3版本和以前的不一样了么,我想设置一下缓存,但是没有显示有这个setCache()方法?

public CacheResponse(File cacheDirectory) throws Exception {
  int cacheSize = 10 * 1024 * 1024; // 10 MiB
  Cache cache = new Cache(cacheDirectory, cacheSize);

  client = new OkHttpClient();
    
  // 此处会提示没有这个setCache(),我用的eclipse
  client.setCache(cache);
}
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

membalas semua(2)
左手右手慢动作

3.3 Gunakan Builder untuk menyediakan Cache

OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.cache(cache);
OkHttpClient client = builder.build();
Ty80

Kod okhttp 3.3 telah banyak diubah suai. Lihatlah kelas dalaman yang dipanggil InternalCache

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan