Class PersistentLicenseCache
java.lang.Object
org.codehaus.mojo.license.download.PersistentLicenseCache
A cache of downloaded license texts that outlives the build. One file per URL, named after the SHA-256 of the URL,
holds a small header (URL, download time, content type, validators) followed by the bytes exactly as the server sent
them. Because everything is in one file, replacing it with an atomic move is enough for builds that share the cache
directory: a reader sees the old entry or the new one, never half of either.
- Since:
- 2.8.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA cache entry.static enumWhere the text of a license came from. -
Constructor Summary
ConstructorsConstructorDescriptionPersistentLicenseCache(Path directory, Duration timeToLive, boolean readEnabled) -
Method Summary
Modifier and TypeMethodDescriptionintcount(PersistentLicenseCache.Source source) booleanvoidrecord(PersistentLicenseCache.Source source) voidRestarts the time to live ofentryafter the server confirmed it.voidWrites the entry forurl, replacing an older one.
-
Constructor Details
-
PersistentLicenseCache
- Parameters:
directory- where the entries live; created on the first writetimeToLive- how long an entry is served without asking the serverreadEnabled- whenfalse,find(String)finds nothing, butstore(String, byte[], String, String, String)still refreshes the entries
-
-
Method Details
-
getDirectory
-
find
- Parameters:
url- the final download URL- Returns:
- the entry for
url, fresh or not, ornullif there is none, it cannot be read or reading is disabled
-
isFresh
- Parameters:
entry- an entry returned byfind(String)- Returns:
trueifentrymay be used without asking the server
-
store
-
refresh
Restarts the time to live ofentryafter the server confirmed it. -
record
-
count
-