admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
fanli/src/main/java/com/yeshi/fanli/util/EhcacheUtil.java
@@ -1,48 +1,48 @@
package com.yeshi.fanli.util;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.CacheConfiguration;
public class EhcacheUtil {
   public static CacheManager cacheManager = CacheManager.getInstance();
   public static Cache addCahae(CacheConfiguration cacheConfiguration){
      cacheManager.addCache(new Cache(cacheConfiguration));
      return cacheManager.getCache(cacheConfiguration.getName());
   }
   public static void removeCache(String name){
      cacheManager.removeCache(name);
   }
   public static Cache getCache(String name){
      return cacheManager.getCache(name);
   }
   public static CacheConfiguration getMyPubCacheConfig(String name){
      CacheConfiguration cacheConfiguration = new CacheConfiguration();
      cacheConfiguration.setMaxElementsInMemory(1000);
      cacheConfiguration.setMaxElementsOnDisk(10000);
      cacheConfiguration.setEternal(false);
      cacheConfiguration.setTimeToIdleSeconds(Constant.DAYMS);
      cacheConfiguration.setTimeToLiveSeconds(Constant.DAYMS);
      cacheConfiguration.setOverflowToDisk(true);
      cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
      cacheConfiguration.setName(name);
      return cacheConfiguration;
   }
   public static CacheConfiguration getOneDayCacheConfig(String name){
      CacheConfiguration cacheConfiguration = new CacheConfiguration();
      cacheConfiguration.setMaxElementsInMemory(1000);
      cacheConfiguration.setMaxElementsOnDisk(10000);
      cacheConfiguration.setEternal(false);
      cacheConfiguration.setTimeToLiveSeconds(86400000);
      cacheConfiguration.setOverflowToDisk(true);
      cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
      cacheConfiguration.setName(name);
      return cacheConfiguration;
   }
}
package com.yeshi.fanli.util;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.CacheConfiguration;
public class EhcacheUtil {
   public static CacheManager cacheManager = CacheManager.getInstance();
   public static Cache addCahae(CacheConfiguration cacheConfiguration){
      cacheManager.addCache(new Cache(cacheConfiguration));
      return cacheManager.getCache(cacheConfiguration.getName());
   }
   public static void removeCache(String name){
      cacheManager.removeCache(name);
   }
   public static Cache getCache(String name){
      return cacheManager.getCache(name);
   }
   public static CacheConfiguration getMyPubCacheConfig(String name){
      CacheConfiguration cacheConfiguration = new CacheConfiguration();
      cacheConfiguration.setMaxElementsInMemory(1000);
      cacheConfiguration.setMaxElementsOnDisk(10000);
      cacheConfiguration.setEternal(false);
      cacheConfiguration.setTimeToIdleSeconds(Constant.DAYMS);
      cacheConfiguration.setTimeToLiveSeconds(Constant.DAYMS);
      cacheConfiguration.setOverflowToDisk(true);
      cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
      cacheConfiguration.setName(name);
      return cacheConfiguration;
   }
   public static CacheConfiguration getOneDayCacheConfig(String name){
      CacheConfiguration cacheConfiguration = new CacheConfiguration();
      cacheConfiguration.setMaxElementsInMemory(1000);
      cacheConfiguration.setMaxElementsOnDisk(10000);
      cacheConfiguration.setEternal(false);
      cacheConfiguration.setTimeToLiveSeconds(86400000);
      cacheConfiguration.setOverflowToDisk(true);
      cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
      cacheConfiguration.setName(name);
      return cacheConfiguration;
   }
}