Class JCSCacheManager
- java.lang.Object
-
- org.openstreetmap.josm.data.cache.JCSCacheManager
-
public final class JCSCacheManager extends java.lang.Object
Wrapper class for JCS Cache. Sets some sane environment and returns instances of cache objects. Static configuration for now assumes some small LRU cache in memory and larger LRU cache on disk- Since:
- 8168
-
-
Field Summary
Fields Modifier and Type Field Description private static java.nio.channels.FileLock
cacheDirLock
static IntegerProperty
DEFAULT_MAX_OBJECTS_IN_MEMORY
default objects to be held in memory by JCS caches (per region)private static org.apache.commons.jcs3.auxiliary.AuxiliaryCacheFactory
DISK_CACHE_FACTORY
private static java.util.logging.Logger
jcsLog
private static long
MAX_OBJECT_TTL
private static java.lang.String
PREFERENCE_PREFIX
static BooleanProperty
USE_BLOCK_CACHE
Property that determines the disk cache implementation
-
Constructor Summary
Constructors Modifier Constructor Description private
JCSCacheManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
deleteCacheFiles(java.lang.String basePathPart)
static <K,V>
org.apache.commons.jcs3.access.CacheAccess<K,V>getCache(java.lang.String cacheName)
Returns configured cache object for named cache regionstatic <K,V>
org.apache.commons.jcs3.access.CacheAccess<K,V>getCache(java.lang.String cacheName, int maxMemoryObjects, int maxDiskObjects, java.lang.String cachePath)
Returns configured cache object with defined limits of memory cache and disk cacheprivate static <K,V>
org.apache.commons.jcs3.access.CacheAccess<K,V>getCacheAccess(java.lang.String cacheName, org.apache.commons.jcs3.engine.CompositeCacheAttributes cacheAttributes)
private static org.apache.commons.jcs3.engine.CompositeCacheAttributes
getCacheAttributes(int maxMemoryElements)
private static org.apache.commons.jcs3.auxiliary.disk.behavior.IDiskCacheAttributes
getDiskCacheAttributes(int maxDiskObjects, java.lang.String cachePath, java.lang.String cacheName)
private static org.apache.commons.jcs3.auxiliary.AuxiliaryCacheFactory
getDiskCacheFactory()
private static void
removeStaleFiles(java.lang.String basePathPart, java.lang.String suffix)
static void
shutdown()
Close all files to ensure, that all indexes and data are properly writtenprivate static boolean
useBlockCache()
-
-
-
Field Detail
-
MAX_OBJECT_TTL
private static final long MAX_OBJECT_TTL
- See Also:
- Constant Field Values
-
PREFERENCE_PREFIX
private static final java.lang.String PREFERENCE_PREFIX
- See Also:
- Constant Field Values
-
USE_BLOCK_CACHE
public static final BooleanProperty USE_BLOCK_CACHE
Property that determines the disk cache implementation
-
DISK_CACHE_FACTORY
private static final org.apache.commons.jcs3.auxiliary.AuxiliaryCacheFactory DISK_CACHE_FACTORY
-
cacheDirLock
private static java.nio.channels.FileLock cacheDirLock
-
DEFAULT_MAX_OBJECTS_IN_MEMORY
public static final IntegerProperty DEFAULT_MAX_OBJECTS_IN_MEMORY
default objects to be held in memory by JCS caches (per region)
-
jcsLog
private static final java.util.logging.Logger jcsLog
-
-
Constructor Detail
-
JCSCacheManager
private JCSCacheManager()
-
-
Method Detail
-
getDiskCacheFactory
private static org.apache.commons.jcs3.auxiliary.AuxiliaryCacheFactory getDiskCacheFactory()
-
useBlockCache
private static boolean useBlockCache()
-
getCache
public static <K,V> org.apache.commons.jcs3.access.CacheAccess<K,V> getCache(java.lang.String cacheName)
Returns configured cache object for named cache region- Type Parameters:
K
- key typeV
- value type- Parameters:
cacheName
- region name- Returns:
- cache access object
-
getCache
public static <K,V> org.apache.commons.jcs3.access.CacheAccess<K,V> getCache(java.lang.String cacheName, int maxMemoryObjects, int maxDiskObjects, java.lang.String cachePath)
Returns configured cache object with defined limits of memory cache and disk cache- Type Parameters:
K
- key typeV
- value type- Parameters:
cacheName
- region namemaxMemoryObjects
- number of objects to keep in memorymaxDiskObjects
- maximum size of the objects stored on disk in kBcachePath
- path to disk cache. if null, no disk cache will be created- Returns:
- cache access object
-
getCacheAccess
private static <K,V> org.apache.commons.jcs3.access.CacheAccess<K,V> getCacheAccess(java.lang.String cacheName, org.apache.commons.jcs3.engine.CompositeCacheAttributes cacheAttributes)
-
shutdown
public static void shutdown()
Close all files to ensure, that all indexes and data are properly written
-
getDiskCacheAttributes
private static org.apache.commons.jcs3.auxiliary.disk.behavior.IDiskCacheAttributes getDiskCacheAttributes(int maxDiskObjects, java.lang.String cachePath, java.lang.String cacheName)
-
removeStaleFiles
private static void removeStaleFiles(java.lang.String basePathPart, java.lang.String suffix)
-
deleteCacheFiles
private static void deleteCacheFiles(java.lang.String basePathPart)
-
getCacheAttributes
private static org.apache.commons.jcs3.engine.CompositeCacheAttributes getCacheAttributes(int maxMemoryElements)
-
-