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

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

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

Cache.evictAll介绍

[英]Deletes all values stored in the cache. In-flight writes to the cache will complete normally, but the corresponding responses will not be stored.
[中]删除缓存中存储的所有值。飞行中对缓存的写入将正常完成,但不会存储相应的响应。

代码示例

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

public RewriteResponseCacheControl(File cacheDirectory) throws Exception {
 Cache cache = new Cache(cacheDirectory, 1024 * 1024);
 cache.evictAll();
 client = new OkHttpClient.Builder()
   .cache(cache)
   .build();
}

代码示例来源:origin: stackoverflow.com

import org.hibernate.Cache;
import org.hibernate.SessionFactory;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component("CacheManagerMBean")
public class CacheManagerMBean {

  private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CacheManagerMBean.class);

  @Resource(name = "sessionFactory")
  private SessionFactory sessionFactory;

  public void clearCache() {
    Cache cache = sessionFactory.getCache();
    if (null != cache) {
      logger.info("Clearing cache...");
      cache.evictAll();
      cache.evictAllRegions();
      logger.info("Clearing cache...Done!");
    } else {
      logger.error("No second level cache available for session-factory");
    }
  }

}

代码示例来源:origin: palaima/DebugDrawer

private void clearCache() {
  try {
    client.cache().evictAll();
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: stackoverflow.com

public static MyMessage saveOrUpdate(MyMessage msg) {
  ...
  EntityManager em1 = factory.createEntityManager();
  Cache cache = em1.getEntityManagerFactory().getCache(); // get cache 
  cache.evictAll(); // remove all Entity from Cache
  MyMessage msss= em1.find(MyMessage.class, m.getId());
  System.out.println(msss);// prints null
  return m;
}

相关文章