List of usage examples for org.apache.commons.jcs.auxiliary.disk.behavior IDiskCacheAttributes setCacheName
void setCacheName(String s);
From source file:org.openstreetmap.josm.data.cache.JCSCacheManager.java
private static IDiskCacheAttributes getDiskCacheAttributes(int maxDiskObjects, String cachePath, String cacheName) {/*from w w w . j av a 2 s . c om*/ IDiskCacheAttributes ret; removeStaleFiles(cachePath + File.separator + cacheName, USE_BLOCK_CACHE.get() ? "_INDEX_v2" : "_BLOCK_v2"); String newCacheName = cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK_v2" : "_INDEX_v2"); if (USE_BLOCK_CACHE.get()) { BlockDiskCacheAttributes blockAttr = new BlockDiskCacheAttributes(); /* * BlockDiskCache never optimizes the file, so when file size is reduced, it will never be truncated to desired size. * * If for some mysterious reason, file size is greater than the value set in preferences, just use the whole file. If the user * wants to reduce the file size, (s)he may just go to preferences and there it should be handled (by removing old file) */ File diskCacheFile = new File(cachePath + File.separator + newCacheName + ".data"); if (diskCacheFile.exists()) { blockAttr.setMaxKeySize((int) Math.max(maxDiskObjects, diskCacheFile.length() / 1024)); } else { blockAttr.setMaxKeySize(maxDiskObjects); } blockAttr.setBlockSizeBytes(4096); // use 4k blocks ret = blockAttr; } else { IndexedDiskCacheAttributes indexAttr = new IndexedDiskCacheAttributes(); indexAttr.setMaxKeySize(maxDiskObjects); ret = indexAttr; } ret.setDiskLimitType(IDiskCacheAttributes.DiskLimitType.SIZE); File path = new File(cachePath); if (!path.exists() && !path.mkdirs()) { LOG.log(Level.WARNING, "Failed to create cache path: {0}", cachePath); } else { ret.setDiskPath(cachePath); } ret.setCacheName(newCacheName); return ret; }