This Gradle plugin provides a build cache implementation that uses Redis to store build artifacts.
The build cache takes the following options:
Option | System property | Default value |
---|---|---|
host |
net.idlestate.gradle.caching.redis.host |
localhost |
port |
net.idlestate.gradle.caching.redis.port |
6379 |
password |
net.idlestate.gradle.caching.redis.password |
<no password> |
timeToLive |
net.idlestate.gradle.caching.redis.ttl |
14400 (10 days in minutes) |
There are multiple ways to use the Redis based build cache inside your projects.
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'net.idlestate:gradle-redis-build-cache:1.3.0'
}
}
apply plugin: 'net.idlestate.gradle-redis-build-cache'
buildCache {
local {
enabled = false
}
}
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'net.idlestate:gradle-redis-build-cache:1.3.0'
}
}
import net.idlestate.gradle.caching.RedisBuildCache
import net.idlestate.gradle.caching.RedisBuildCacheServiceFactory
buildCache {
local {
enabled = false
}
registerBuildCacheService( RedisBuildCache.class, RedisBuildCacheServiceFactory.class )
remote( RedisBuildCache.class ) {
host = '127.0.0.1'
port = 6379
timeToLive = 2*24*60 // two days in minutes
enabled = true
push = true
}
}
initscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'net.idlestate:gradle-redis-build-cache:1.3.0'
}
}
import net.idlestate.gradle.caching.RedisBuildCache
import net.idlestate.gradle.caching.RedisBuildCacheServiceFactory
gradle.settingsEvaluated { settings ->
settings.buildCache {
local {
enabled = false
}
registerBuildCacheService( RedisBuildCache.class, RedisBuildCacheServiceFactory.class )
remote( RedisBuildCache.class ) {
host = '127.0.0.1'
port = 6379
enabled = true
push = true
}
}
}
% ./gradlew --build-cache --init-script init-build-cache.gradle <task>
The plugin tracks some values to analyse the cache utilisation and adjust the cache and redis settings.
Purpose | Redis key format | Values | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Daily usage |
statistic_YYYY-MM-DD |
|
||||||||||||
Key specific usage |
key_statistic_KEY |
|