@CompileStatic final class Cache extends Object
Provides a local file cache.
Modifiers | Name | Description |
---|---|---|
static class |
Cache.Key |
|
static enum |
Cache.LogLevel |
Constructor and description |
---|
Cache
() |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
clear(Gradle gradle) Deletes the whole cache. |
|
void |
delete(Gradle gradle, Cache.Key key) Deletes an entry from the cache. |
|
boolean |
get(Gradle gradle, Cache.Key key, Consumer<? super InputStream> consumer) Reads from the cache using an java.io.InputStream . |
|
static Cache |
getInstance() |
|
boolean |
has(Gradle gradle, Cache.Key key) Queries the existence of a key in the cache. |
|
static Cache.Key |
key(Object input) Creates a Key instance based on the given input |
|
long |
lastModified(Gradle gradle, Cache.Key key) Returns the last modification timestamp of the given Key .
|
|
boolean |
put(Gradle gradle, Cache.Key key, Consumer<? super OutputStream> consumer) Writes to the cache using an java.io.OutputStream . |
|
boolean |
read(Gradle gradle, Cache.Key key, Consumer<? super BufferedReader> consumer) Reads from the cache using a java.io.BufferedReader . |
|
static Cache.LogLevel |
resolveLogLevel() |
|
long |
touch(Gradle gradle, Cache.Key key) Updates the last modification timestamp of the given Key .
|
|
boolean |
write(Gradle gradle, Cache.Key key, Consumer<? super BufferedWriter> consumer) Writes to the cache using a java.io.BufferedWriter . |
Deletes the whole cache.
gradle
- the Gradle
instance that owns the cacheDeletes an entry from the cache.
gradle
- the Gradle
instance that owns the cachekey
- the key that identifies the cache entry Reads from the cache using an java.io.InputStream
.
gradle
- the Gradle
instance that owns the cachekey
- the key that identifies the cache entryconsumer
- the function that reads from the cachetrue
if the read was successful, false
otherwise.Queries the existence of a key in the cache.
gradle
- the Gradle
instance that owns the cachekey
- the key to be searchedtrue
if the key is found, false
otherwise. Creates a Key
instance based on the given input
input
- the key's contents Returns the last modification timestamp of the given Key
.
Returns Long.MIN_VALUE
if a matching key is not found.
gradle
- the Gradle
instance that owns the cachekey
- the key that identifies the cache entry Writes to the cache using an java.io.OutputStream
.
gradle
- the Gradle
instance that owns the cachekey
- the key that identifies the cache entryconsumer
- the function that writes to the cachetrue
if the write was successful, false
otherwise. Reads from the cache using a java.io.BufferedReader
.
gradle
- the Gradle
instance that owns the cachekey
- the key that identifies the cache entryconsumer
- the function that reads from the cachetrue
if the read was successful, false
otherwise. Updates the last modification timestamp of the given Key
.
Returns Long.MIN_VALUE
if a matching key is not found.
gradle
- the Gradle
instance that owns the cachekey
- the key that identifies the cache entry Writes to the cache using a java.io.BufferedWriter
.
gradle
- the Gradle
instance that owns the cachekey
- the key that identifies the cache entryconsumer
- the function that writes to the cachetrue
if the write was successful, false
otherwise.