okhttp3.Cache.key()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中okhttp3.Cache.key()方法的一些代码示例,展示了Cache.key()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.key()方法的具体详情如下:
包路径:okhttp3.Cache
类名称:Cache
方法名:key

Cache.key介绍

暂无

代码示例

代码示例来源:origin: square/okhttp

void remove(Request request) throws IOException {
 cache.remove(key(request.url()));
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

void remove(Request request) throws IOException {
 cache.remove(key(request.url()));
}

代码示例来源:origin: square/okhttp

DiskLruCache.Editor editor = null;
try {
 editor = cache.edit(key(response.request().url()));
 if (editor == null) {
  return null;

代码示例来源:origin: square/okhttp

@Nullable Response get(Request request) {
 String key = key(request.url());
 DiskLruCache.Snapshot snapshot;
 Entry entry;
 try {
  snapshot = cache.get(key);
  if (snapshot == null) {
   return null;
  }
 } catch (IOException e) {
  // Give up because the cache cannot be read.
  return null;
 }
 try {
  entry = new Entry(snapshot.getSource(ENTRY_METADATA));
 } catch (IOException e) {
  Util.closeQuietly(snapshot);
  return null;
 }
 Response response = entry.response(snapshot);
 if (!entry.matches(request, response)) {
  Util.closeQuietly(response.body());
  return null;
 }
 return response;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

DiskLruCache.Editor editor = null;
try {
 editor = cache.edit(key(response.request().url()));
 if (editor == null) {
  return null;

代码示例来源:origin: com.squareup.okhttp3/okhttp

@Nullable Response get(Request request) {
 String key = key(request.url());
 DiskLruCache.Snapshot snapshot;
 Entry entry;
 try {
  snapshot = cache.get(key);
  if (snapshot == null) {
   return null;
  }
 } catch (IOException e) {
  // Give up because the cache cannot be read.
  return null;
 }
 try {
  entry = new Entry(snapshot.getSource(ENTRY_METADATA));
 } catch (IOException e) {
  Util.closeQuietly(snapshot);
  return null;
 }
 Response response = entry.response(snapshot);
 if (!entry.matches(request, response)) {
  Util.closeQuietly(response.body());
  return null;
 }
 return response;
}

代码示例来源:origin: com.github.ljun20160606/okhttp

void remove(Request request) throws IOException {
 cache.remove(key(request.url()));
}

代码示例来源:origin: apache/servicemix-bundles

void remove(Request request) throws IOException {
 cache.remove(key(request.url()));
}

代码示例来源:origin: com.github.ljun20160606/okhttp

DiskLruCache.Editor editor = null;
try {
 editor = cache.edit(key(response.request().url()));
 if (editor == null) {
  return null;

代码示例来源:origin: apache/servicemix-bundles

DiskLruCache.Editor editor = null;
try {
 editor = cache.edit(key(response.request().url()));
 if (editor == null) {
  return null;

代码示例来源:origin: com.github.ljun20160606/okhttp

@Nullable Response get(Request request) {
 String key = key(request.url());
 DiskLruCache.Snapshot snapshot;
 Entry entry;
 try {
  snapshot = cache.get(key);
  if (snapshot == null) {
   return null;
  }
 } catch (IOException e) {
  // Give up because the cache cannot be read.
  return null;
 }
 try {
  entry = new Entry(snapshot.getSource(ENTRY_METADATA));
 } catch (IOException e) {
  Util.closeQuietly(snapshot);
  return null;
 }
 Response response = entry.response(snapshot);
 if (!entry.matches(request, response)) {
  Util.closeQuietly(response.body());
  return null;
 }
 return response;
}

代码示例来源:origin: apache/servicemix-bundles

@Nullable Response get(Request request) {
 String key = key(request.url());
 DiskLruCache.Snapshot snapshot;
 Entry entry;
 try {
  snapshot = cache.get(key);
  if (snapshot == null) {
   return null;
  }
 } catch (IOException e) {
  // Give up because the cache cannot be read.
  return null;
 }
 try {
  entry = new Entry(snapshot.getSource(ENTRY_METADATA));
 } catch (IOException e) {
  Util.closeQuietly(snapshot);
  return null;
 }
 Response response = entry.response(snapshot);
 if (!entry.matches(request, response)) {
  Util.closeQuietly(response.body());
  return null;
 }
 return response;
}

相关文章