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

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

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

Cache.close介绍

暂无

代码示例

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

/**
 * Uninstalls the cache and releases any active resources. Stored contents will remain on the
 * filesystem.
 */
public void close() throws IOException {
 delegate.close();
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void destroy() throws IOException {
  if (this.defaultClient) {
    // Clean up the client if we created it in the constructor
    Cache cache = this.client.cache();
    if (cache != null) {
      cache.close();
    }
    this.client.dispatcher().executorService().shutdown();
  }
}

代码示例来源:origin: org.springframework/spring-web

@Override
public void destroy() throws IOException {
  if (this.defaultClient) {
    // Clean up the client if we created it in the constructor
    Cache cache = this.client.cache();
    if (cache != null) {
      cache.close();
    }
    this.client.dispatcher().executorService().shutdown();
  }
}

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

/** Stops this instance from accepting further requests. */
public void shutdown() {
 if (shutdown) {
  return;
 }
 cache.clear();
 stats.shutdown();
 dispatcher.shutdown();
 if (closeableCache != null) {
  try {
   closeableCache.close();
  } catch (IOException ignored) {
  }
 }
 for (DeferredRequestCreator deferredRequestCreator : targetToDeferredRequestCreator.values()) {
  deferredRequestCreator.cancel();
 }
 targetToDeferredRequestCreator.clear();
 shutdown = true;
}

代码示例来源:origin: JakeWharton/picasso2-okhttp3-downloader

@Override public void shutdown() {
  if (cache != null) {
   try {
    cache.close();
   } catch (IOException ignored) {
   }
  }
 }
}

代码示例来源:origin: com.jakewharton.picasso/picasso2-okhttp3-downloader

@Override public void shutdown() {
  if (cache != null) {
   try {
    cache.close();
   } catch (IOException ignored) {
   }
  }
 }
}

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

/**
 * Uninstalls the cache and releases any active resources. Stored contents will remain on the
 * filesystem.
 */
public void close() throws IOException {
 delegate.close();
}

代码示例来源:origin: com.adobe.aam/metrics-opentsdb

@Override
public void shutdown() {
  try {
    Cache cache = client.cache();
    if (cache != null) {
      cache.flush();
      cache.close();
    }
  } catch (IOException e) {
    logger.error("Error while trying shutdown OpenTSDB publisher", e);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

@Override
public void destroy() throws IOException {
  if (this.defaultClient) {
    // Clean up the client if we created it in the constructor
    Cache cache = this.client.cache();
    if (cache != null) {
      cache.close();
    }
    this.client.dispatcher().executorService().shutdown();
  }
}

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

@Override
public void destroy() throws IOException {
  if (this.defaultClient) {
    // Clean up the client if we created it in the constructor
    Cache cache = this.client.cache();
    if (cache != null) {
      cache.close();
    }
    this.client.dispatcher().executorService().shutdown();
  }
}

代码示例来源:origin: Clarifai/clarifai-java

private static void closeOkHttpClient(@NotNull OkHttpClient client) {
 client.dispatcher().executorService().shutdown();
 client.connectionPool().evictAll();
 final Cache cache = client.cache();
 if (cache != null) {
  try {
   cache.close();
  } catch (IOException ignored) {
  }
 }
}

代码示例来源:origin: theotherp/nzbhydra2

@Override
public void destroy() throws IOException {
  // Clean up the client if we created it in the constructor
  try {
    if (this.client.cache() != null) {
      this.client.cache().close();
    }
    this.client.dispatcher().executorService().shutdown();
  } catch (NullPointerException e) {
    //Ignore
  }
}

代码示例来源:origin: iNPUTmice/caas

private static void shutdown(OkHttpClient client) throws IOException {
    client.dispatcher().executorService().shutdown();
    client.connectionPool().evictAll();
    final Cache cache = client.cache();
    if (cache != null) {
      cache.close();
    }
  }
}

代码示例来源:origin: marklogic/java-client-api

@Override
public void release() {
 if ( client == null ) return;
 try {
  released = true;
  client.dispatcher().executorService().shutdownNow();
 } finally {
  try {
   if ( client.cache() != null ) client.cache().close();
  } catch (IOException e) {
   throw new MarkLogicIOException(e);
  } finally {
   client = null;
   logger.debug("Releasing connection");
  }
 }
}

代码示例来源:origin: de.dentrassi.iot/de.dentrassi.iot.opentsdb.collector.http

@Override
public void close() throws IOException {
  if (this.client.dispatcher() != null && this.client.dispatcher().executorService() != null) {
    this.client.dispatcher().executorService().shutdown();
  }
  if (this.client.connectionPool() != null) {
    this.client.connectionPool().evictAll();
  }
  if (this.client.cache() != null) {
    this.client.cache().close();
  }
}

代码示例来源:origin: org.openksavi.sponge/sponge-rest-api-client

/**
   * Closes aggressively a OkHttpClient according to the OkHttpClient documentation.
   *
   * @param okHttpClient the OkHttpClient.
   */
  public static void closeOkHttpClient(OkHttpClient okHttpClient) {
    if (okHttpClient.dispatcher() != null && okHttpClient.dispatcher().executorService() != null) {
      okHttpClient.dispatcher().executorService().shutdown();
    }

    if (okHttpClient.connectionPool() != null) {
      okHttpClient.connectionPool().evictAll();
    }

    if (okHttpClient.cache() != null) {
      try {
        okHttpClient.cache().close();
      } catch (IOException e) {
        throw new SpongeException(e);
      }
    }
  }
}

相关文章