Ignore:
Timestamp:
2016-06-18T15:26:31+02:00 (8 years ago)
Author:
wiktorn
Message:

Fix block cache growing outside the limit.

  • Missing setting of the block size prevented JCS to properly limit of the cache file size when using Block Disk. Set the block size to 4096
  • Block Disk Cache do not reduce the size of the file, when setting the limit lower than the actual file size, so now JOSM will remove all the cache files by itself when limit is set to lower than before value
  • Because of above two, bumped naming of the files to _v2 so older (possibly way above the file size limit) file will be removed

See: #12979, #12986

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java

    r10406 r10417  
    4545    private static long maxObjectTTL = -1;
    4646    private static final String PREFERENCE_PREFIX = "jcs.cache";
    47     private static BooleanProperty USE_BLOCK_CACHE = new BooleanProperty(PREFERENCE_PREFIX + ".use_block_cache", true);
     47    public static BooleanProperty USE_BLOCK_CACHE = new BooleanProperty(PREFERENCE_PREFIX + ".use_block_cache", true);
    4848
    4949    private static final AuxiliaryCacheFactory diskCacheFactory =
     
    203203            BlockDiskCacheAttributes blockAttr = new BlockDiskCacheAttributes();
    204204            blockAttr.setMaxKeySize(maxDiskObjects);
     205            blockAttr.setBlockSizeBytes(4096); // use 4k blocks
    205206            ret = blockAttr;
    206207        } else {
     
    216217            ret.setDiskPath(cachePath);
    217218        }
    218         ret.setCacheName(cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK" : "_INDEX"));
    219 
    220         removeStaleFiles(cachePath + File.separator + cacheName, (USE_BLOCK_CACHE.get() ? "_INDEX" : "_BLOCK"));
     219        ret.setCacheName(cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK_v2" : "_INDEX_v2"));
     220
     221        removeStaleFiles(cachePath + File.separator + cacheName, (USE_BLOCK_CACHE.get() ? "_INDEX_v2" : "_BLOCK_v2"));
    221222        return ret;
    222223    }
     
    224225    private static void removeStaleFiles(String basePathPart, String suffix) {
    225226        deleteCacheFiles(basePathPart); // TODO: this can be removed around 2016.09
     227        deleteCacheFiles(basePathPart + "_BLOCK"); // TODO: this can be removed around 2016.09
     228        deleteCacheFiles(basePathPart + "_INDEX"); // TODO: this can be removed around 2016.09
    226229        deleteCacheFiles(basePathPart + suffix);
    227230    }
Note: See TracChangeset for help on using the changeset viewer.