Changeset 12811 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2017-09-10T00:48:43+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r12765 r12811 42 42 public final class JCSCacheManager { 43 43 private static volatile CompositeCacheManager cacheManager; 44 private static long maxObjectTTL = -1;44 private static final long maxObjectTTL = -1; 45 45 private static final String PREFERENCE_PREFIX = "jcs.cache"; 46 46 public static final BooleanProperty USE_BLOCK_CACHE = new BooleanProperty(PREFERENCE_PREFIX + ".use_block_cache", true); … … 55 55 public static final IntegerProperty DEFAULT_MAX_OBJECTS_IN_MEMORY = new IntegerProperty(PREFERENCE_PREFIX + ".max_objects_in_memory", 1000); 56 56 57 private JCSCacheManager() { 58 // Hide implicit public constructor for utility classes 59 } 60 61 @SuppressWarnings("resource") 62 private static void initialize() throws IOException { 63 File cacheDir = new File(Main.pref.getCacheDirectory(), "jcs"); 64 65 if (!cacheDir.exists() && !cacheDir.mkdirs()) 66 throw new IOException("Cannot access cache directory"); 67 68 File cacheDirLockPath = new File(cacheDir, ".lock"); 69 if (!cacheDirLockPath.exists() && !cacheDirLockPath.createNewFile()) { 70 Logging.warn("Cannot create cache dir lock file"); 71 } 72 cacheDirLock = new FileOutputStream(cacheDirLockPath).getChannel().tryLock(); 73 74 if (cacheDirLock == null) 75 Logging.warn("Cannot lock cache directory. Will not use disk cache"); 76 57 private static final Logger jcsLog; 58 59 static { 77 60 // raising logging level gives ~500x performance gain 78 61 // http://westsworld.dk/blog/2008/01/jcs-and-performance/ 79 final LoggerjcsLog = Logger.getLogger("org.apache.commons.jcs");62 jcsLog = Logger.getLogger("org.apache.commons.jcs"); 80 63 jcsLog.setLevel(Level.INFO); 81 64 jcsLog.setUseParentHandlers(false); … … 110 93 } 111 94 }); 95 }; 96 97 private JCSCacheManager() { 98 // Hide implicit public constructor for utility classes 99 } 100 101 @SuppressWarnings("resource") 102 private static void initialize() throws IOException { 103 File cacheDir = new File(Main.pref.getCacheDirectory(), "jcs"); 104 105 if (!cacheDir.exists() && !cacheDir.mkdirs()) 106 throw new IOException("Cannot access cache directory"); 107 108 File cacheDirLockPath = new File(cacheDir, ".lock"); 109 if (!cacheDirLockPath.exists() && !cacheDirLockPath.createNewFile()) { 110 Logging.warn("Cannot create cache dir lock file"); 111 } 112 cacheDirLock = new FileOutputStream(cacheDirLockPath).getChannel().tryLock(); 113 114 if (cacheDirLock == null) 115 Logging.warn("Cannot lock cache directory. Will not use disk cache"); 112 116 113 117 // this could be moved to external file
Note:
See TracChangeset
for help on using the changeset viewer.