- Timestamp:
- 2016-07-26T22:06:52+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r10570 r10652 45 45 private static long maxObjectTTL = -1; 46 46 private static final String PREFERENCE_PREFIX = "jcs.cache"; 47 public static BooleanProperty USE_BLOCK_CACHE = new BooleanProperty(PREFERENCE_PREFIX + ".use_block_cache", true);47 public static final BooleanProperty USE_BLOCK_CACHE = new BooleanProperty(PREFERENCE_PREFIX + ".use_block_cache", true); 48 48 49 49 private static final AuxiliaryCacheFactory diskCacheFactory = … … 173 173 if (cachePath != null && cacheDirLock != null) { 174 174 IDiskCacheAttributes diskAttributes = getDiskCacheAttributes(maxDiskObjects, cachePath, cacheName); 175 /*176 * BlockDiskCache never optimizes the file, so when file size is reduced, it will never be truncated to desired size.177 *178 * If for some mysterious reason, file size is greater than the value set in preferences, just use the whole file. If the user179 * wants to reduce the file size, (s)he may just go to preferences and there it should be handled (by removing old file)180 */181 if (USE_BLOCK_CACHE.get()) {182 File diskCacheFile = new File(cachePath + File.separator + diskAttributes.getCacheName() + ".data");183 maxDiskObjects = (int) Math.max(maxDiskObjects, diskCacheFile.length()/1024);184 }185 175 try { 186 176 if (cc.getAuxCaches().length == 0) { … … 210 200 private static IDiskCacheAttributes getDiskCacheAttributes(int maxDiskObjects, String cachePath, String cacheName) { 211 201 IDiskCacheAttributes ret; 202 removeStaleFiles(cachePath + File.separator + cacheName, (USE_BLOCK_CACHE.get() ? "_INDEX_v2" : "_BLOCK_v2")); 203 cacheName = cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK_v2" : "_INDEX_v2"); 204 212 205 if (USE_BLOCK_CACHE.get()) { 213 206 BlockDiskCacheAttributes blockAttr = new BlockDiskCacheAttributes(); 214 blockAttr.setMaxKeySize(maxDiskObjects); 207 /* 208 * BlockDiskCache never optimizes the file, so when file size is reduced, it will never be truncated to desired size. 209 * 210 * If for some mysterious reason, file size is greater than the value set in preferences, just use the whole file. If the user 211 * wants to reduce the file size, (s)he may just go to preferences and there it should be handled (by removing old file) 212 */ 213 File diskCacheFile = new File(cachePath + File.separator + cacheName + ".data"); 214 if (diskCacheFile.exists()) { 215 blockAttr.setMaxKeySize((int) Math.max(maxDiskObjects, diskCacheFile.length()/1024)); 216 } else { 217 blockAttr.setMaxKeySize(maxDiskObjects); 218 } 215 219 blockAttr.setBlockSizeBytes(4096); // use 4k blocks 216 220 ret = blockAttr; … … 227 231 ret.setDiskPath(cachePath); 228 232 } 229 ret.setCacheName(cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK_v2" : "_INDEX_v2")); 230 231 removeStaleFiles(cachePath + File.separator + cacheName, (USE_BLOCK_CACHE.get() ? "_INDEX_v2" : "_BLOCK_v2")); 233 ret.setCacheName(cacheName); 234 232 235 return ret; 233 236 }
Note:
See TracChangeset
for help on using the changeset viewer.