Class CacheImpl
java.lang.Object
net.adoptopenjdk.icedteaweb.resources.cache.CacheImpl
This class helps maintain the ordering of most recently use cache items across
multiple jvm instances. The LRU information is stored as a properties file in the
root of the file cache directory.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CacheIndexHolderprivate static final Loggerprivate final InfrastructureFileDescriptor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCacheImpl(InfrastructureFileDescriptor recentlyUsed, InfrastructureFileDescriptor cacheDir) -
Method Summary
Modifier and TypeMethodDescription(package private) FileaddToCache(DownloadInfo info, InputStream inputStream) private FilecacheDirFromEntryId(String entryId) private boolean(package private) voidThis will remove all old cache items.(package private) booleanClears the cache by deleting all the Netx cache filescollectAllEntryIdsFromFileSystem(File[] levelOneDirs) private CacheIndexEntrycreateCacheEntry(CacheIndex idx, CacheKey key) private Function<CacheIndexEntry, String> private voidcreateInfoFile(File dir) private CacheFileInfoImplprivate voidprivate voiddeleteAll(Collection<File> files) private voidprivate void(package private) voiddeleteFromCache(URL resourceHref, VersionString version) (package private) voiddeleteFromCache(CacheIdInfo cacheId) (package private) voiddeleteFromCache(CacheKey key) private StringentryIdFromCacheDir(File dir) private StringextractFileNameFromUrl(URL resourceHref) (package private) List<CacheIndexEntry> getAllEntriesInCache(URL resourceHref) Return all valid cache entries with this URL, regardless of whether they have a version or not.(package private) Optional<CacheIndexEntry> getBestMatchingEntryInCache(URL resourceHref, VersionString version) private CacheIndexEntrygetCacheEntry(CacheIndex idx, CacheKey key) private FilegetCacheFile(CacheIndexEntry entry) (package private) FilegetCacheFile(CacheKey key) private StringgetCacheFileName(URL resourceHref) (package private) List<CacheIdInfo> getCacheIds(String filter, boolean includeJnlpPath, boolean includeDomain) private CachedFilegetInfoFile(CacheIndexEntry entry) (package private) static CacheImplprivate long(package private) Optional<CachedFile> getResourceInfo(CacheKey key) (package private) void(package private) booleanReturns whether there is a version of the URL contents in the cache.(package private) booleanisUpToDate(CacheKey key, long lastModified) Returns whether there is a version of the URL contents in the cache and it is up to date.private Fileprivate booleanReturns a boolean indicating if it ok to clear the netx application cache at this point
-
Field Details
-
LOG
-
cacheIndex
-
rootCacheDir
-
-
Constructor Details
-
CacheImpl
- Parameters:
recentlyUsed- file to be used as recently_used filecacheDir- dir with cache
-
-
Method Details
-
getInstance
-
getCacheFile
-
getCacheEntry
-
addToCache
- Throws:
IOException
-
createCacheEntry
-
makeNewCacheDir
-
createInfoFile
-
getResourceInfo
-
isCached
Returns whether there is a version of the URL contents in the cache.- Parameters:
key- the key of the cache entry- Returns:
- whether the cache contains the version
- Throws:
IllegalArgumentException- if the resourceHref is not cacheable
-
isUpToDate
Returns whether there is a version of the URL contents in the cache and it is up to date.- Parameters:
key- the key of the cache entrylastModified- time in millis since epoch of last modification- Returns:
- whether the cache contains the version
- Throws:
IllegalArgumentException- if the resourceHref is not cacheable
-
getBestMatchingEntryInCache
-
getAllEntriesInCache
Return all valid cache entries with this URL, regardless of whether they have a version or not. They are not sorted.- Parameters:
resourceHref-- Returns:
-
getCacheIds
-
createPaneObjectArray
-
invalidateExistingCacheFile
-
deleteFromCache
-
deleteFromCache
-
deleteFromCache
-
createExtractor
-
deleteFilesFromCache
-
clearCache
boolean clearCache()Clears the cache by deleting all the Netx cache filesNote: Because of how our caching system works, deleting jars of another javaws process is using them can be quite disastrous. Hence why Launcher creates lock files and we check for those by calling
okToClearCache()- Returns:
- true if the cache could be cleared and was cleared
-
deleteAll
-
deleteAll
-
deleteDir
-
cleanCache
void cleanCache()This will remove all old cache items. -
collectAllEntryIdsFromFileSystem
-
getMaxSizeInBytes
private long getMaxSizeInBytes() -
getCacheFile
-
getInfoFile
-
entryIdFromCacheDir
-
cacheDirFromEntryId
-
getCacheFileName
-
extractFileNameFromUrl
-
cannotClearCache
private boolean cannotClearCache() -
okToClearCache
private boolean okToClearCache()Returns a boolean indicating if it ok to clear the netx application cache at this point- Returns:
- true if the cache can be cleared at this time without problems
-