本文整理匯總了Java中net.sf.ehcache.config.CacheConfiguration.persistence方法的典型用法代碼示例。如果您正苦於以下問題:Java CacheConfiguration.persistence方法的具體用法?Java CacheConfiguration.persistence怎麽用?Java CacheConfiguration.persistence使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sf.ehcache.config.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.persistence方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initCache
import net.sf.ehcache.config.CacheConfiguration; //導入方法依賴的package包/類
public static void initCache(String bucket) {
if (manager == null) {
load();
}
if (manager.getCache(bucket) != null) {
return;
}
CacheConfiguration config = new CacheConfiguration(bucket, 10000);
//config.setDiskPersistent(false);
//config.setMaxElementsOnDisk(0);
//config.setMaxBytesLocalDisk(0L);
config.setOverflowToOffHeap(false);
PersistenceConfiguration persistenceConfiguration = new PersistenceConfiguration();
persistenceConfiguration.strategy(PersistenceConfiguration.Strategy.NONE);
config.persistence(persistenceConfiguration);
manager.addCache(new Cache(config));
}
示例2: ServletCache
import net.sf.ehcache.config.CacheConfiguration; //導入方法依賴的package包/類
private ServletCache(String name, int type) {
this.type = type;
Configuration managerConfig = new Configuration();
CacheConfiguration mqCf = new CacheConfiguration(name, CacheConfig
.getConfig().getMaxElementsInMemory());
mqCf.setEternal(true);
DiskStoreConfiguration dsCf = new DiskStoreConfiguration();
dsCf.setPath(CacheConfig.getConfig().getDiskStorePath());
managerConfig.addDiskStore(dsCf);
mqCf.setMaxElementsOnDisk(0);
mqCf.setMaxEntriesLocalHeap(CacheConfig.getConfig()
.getMaxElementsInMemory());
mqCf.persistence(new PersistenceConfiguration()
.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP));
mqCf.setTransactionalMode("OFF");
mqCf.setMemoryStoreEvictionPolicy(CacheConfig.getConfig()
.getMemoryStoreEvictionPolicy());
managerConfig.addCache(mqCf);
cacheManager = new CacheManager(managerConfig);
cache = cacheManager.getCache(name);
}
示例3: initCache
import net.sf.ehcache.config.CacheConfiguration; //導入方法依賴的package包/類
public static void initCache(String bucket) {
if (manager == null) {
load();
}
if (manager.getCache(bucket) != null) {
return;
}
synchronized(manager) {
if (manager.getCache(bucket) != null) {
return;
}
CacheConfiguration config = new CacheConfiguration();
config.setName(bucket);
// We have to do this way because there is no way to programmatically configure the
// sizeOfEngine
System.setProperty("net.sf.ehcache.sizeofengine.stallionLocalMemoryCache." + bucket, "io.stallion.dataAccess.filtering.EstimatedSizeOfEngine");
// Max cache size is 100MB
config.setMaxBytesLocalHeap(100 * 1000 * 1000L);
//config.setDiskPersistent(false);
//config.setMaxElementsOnDisk(0);
//config.setMaxBytesLocalDisk(0L);
config.setOverflowToOffHeap(false);
PersistenceConfiguration persistenceConfiguration = new PersistenceConfiguration();
persistenceConfiguration.strategy(PersistenceConfiguration.Strategy.NONE);
config.persistence(persistenceConfiguration);
manager.addCache(new Cache(config));
}
}
示例4: initCache
import net.sf.ehcache.config.CacheConfiguration; //導入方法依賴的package包/類
public static void initCache(String bucket) {
if (manager == null) {
load();
}
if (manager.getCache(bucket) != null) {
return;
}
// We have to do this way because there is no way to programmmatically configured the
// sizeOfEngine
System.setProperty("net.sf.ehcache.sizeofengine.stallionFilterCache." + bucket, "io.stallion.dataAccess.filtering.EstimatedSizeOfEngine");
CacheConfiguration config = new CacheConfiguration();
config.setName(bucket);
// Max cache size is very approximately, 50MB
config.setMaxBytesLocalHeap(Settings.instance().getFilterCacheSize());
//config.setDiskPersistent(false);
//config.setMaxElementsOnDisk(0);
//config.setMaxBytesLocalDisk(0L);
config.setOverflowToOffHeap(false);
PersistenceConfiguration persistenceConfiguration = new PersistenceConfiguration();
persistenceConfiguration.strategy(PersistenceConfiguration.Strategy.NONE);
config.persistence(persistenceConfiguration);
//SizeOfPolicyConfiguration sizeOfPolicyConfiguration = new SizeOfPolicyConfiguration();
//sizeOfPolicyConfiguration.
//config.addSizeOfPolicy();
//config.set
Cache cache = new Cache(config);
manager.addCache(cache);
//Cache cache = manager.getCache(bucket);
//CacheConfiguration config = cache.getCacheConfiguration();
//config.setMaxBytesLocalHeap(150000000L);
}
示例5: PersistQueue
import net.sf.ehcache.config.CacheConfiguration; //導入方法依賴的package包/類
/**
* 構造函數
*
* @param block
* --是否為阻塞隊列,true是阻塞隊列,false是非阻塞隊列
* @param cacheLength
* --內存中隊列長度,值>0;
* @param persistDirPath
* --持久數據落地目錄(<b>注意:一個隊列對應一個目錄路徑,多個隊列共享一個目錄路徑,是不允許的,會出現數據不一致的情況!
* < /b>)
*/
public PersistQueue(final boolean block, final int cacheLength,
final String persistDirPath) {
if (cacheLength < 0) {
throw new AppRuntimeException("cacheLength must >0!");
}
if (block) {
this.tmpQueue = new BlockQueue();
} else {
this.tmpQueue = new NoBlockConcurrentQueue();
}
psKeys = new ConcurrentLinkedQueue<Long>();
hcName = "pq_" + persistDirPath.hashCode();
Configuration managerConfig = new Configuration();
CacheConfiguration mqCf = new CacheConfiguration(hcName, cacheLength);
mqCf.setEternal(true);
// mqCf.setDiskStorePath(persistDirPath);
mqCf.setMaxElementsOnDisk(0);
mqCf.setTransactionalMode("OFF");
mqCf.setMemoryStoreEvictionPolicy("LFU");
// mqCf.setDiskPersistent(true);
// mqCf.setMaxElementsInMemory(cacheLength);
mqCf.setMaxEntriesLocalHeap(cacheLength);
// mqCf.setOverflowToDisk(true);
mqCf.persistence(new PersistenceConfiguration()
.strategy(PersistenceConfiguration.Strategy.LOCALRESTARTABLE));
managerConfig.addCache(mqCf);
DiskStoreConfiguration dsCf = new DiskStoreConfiguration();
dsCf.setPath(persistDirPath);
managerConfig.addDiskStore(dsCf);
cacheManager = new CacheManager(managerConfig);
cache = cacheManager.getCache(hcName);
Element e = cache.get(hcName);
if (null == e) {
count = new AtomicLong(0);
} else {
Long cv = (Long) e.getObjectValue();
count = new AtomicLong(cv.longValue());
}
}
示例6: CacheQueue
import net.sf.ehcache.config.CacheConfiguration; //導入方法依賴的package包/類
/**
* 構造函數
*
* @param block
* --是否為阻塞隊列,true是阻塞隊列,false是非阻塞隊列
* @param cacheLength
* --內存中隊列長度,值>0;
* @param persistDirPath
* --數據落地目錄(<b>注意:一個隊列對應一個目錄路徑,多個隊列共享一個目錄路徑,是不允許的,會出現數據不一致的情況! <
* /b>)
*/
public CacheQueue(final boolean block, final int cacheLength,
final String persistDirPath) {
if (cacheLength < 0) {
throw new AppRuntimeException("cacheLength must >0!");
}
if (block) {
this.tmpQueue = new BlockQueue();
} else {
this.tmpQueue = new NoBlockConcurrentQueue();
}
psKeys = new ConcurrentLinkedQueue<Long>();
hcName = "cq-" + persistDirPath.hashCode();
Configuration managerConfig = new Configuration();
CacheConfiguration mqCf = new CacheConfiguration(hcName, cacheLength);
mqCf.setEternal(true);
// mqCf.setDiskStorePath(persistDirPath);
mqCf.setMaxElementsOnDisk(0);
mqCf.setTransactionalMode("OFF");
mqCf.setMemoryStoreEvictionPolicy("LFU");
// mqCf.setDiskPersistent(true);
// mqCf.setMaxElementsInMemory(cacheLength);
mqCf.setMaxEntriesLocalHeap(cacheLength);
// mqCf.setOverflowToDisk(true);
mqCf.persistence(new PersistenceConfiguration()
.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP));
managerConfig.addCache(mqCf);
DiskStoreConfiguration dsCf = new DiskStoreConfiguration();
dsCf.setPath(persistDirPath);
managerConfig.addDiskStore(dsCf);
managerConfig.setName(hcName);
// cacheManager = new CacheManager(managerConfig);
cacheManager = CacheManager.newInstance(managerConfig);
cache = cacheManager.getCache(hcName);
count = new AtomicLong(0);
}
示例7: MemoryOnlyEhcache
import net.sf.ehcache.config.CacheConfiguration; //導入方法依賴的package包/類
public MemoryOnlyEhcache(String size, String namePrefix)
{
CacheConfiguration config = new CacheConfiguration();
config.setMaxBytesLocalHeap(size);
config.persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE));
config.setMemoryStoreEvictionPolicy("LRU");
config.eternal(true);
config.setName(String.format("%s-%s", namePrefix, UUID.randomUUID().toString()));
cache = new net.sf.ehcache.Cache(config);
CacheManager.getInstance().addCache(cache);
}