gradle-redis-build-cache

Introduction: A Gradle build cache that uses Redis to store build artifacts
More: Author   ReportBugs   
Tags:

This Gradle plugin provides a build cache implementation that uses Redis to store build artifacts.

Options

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 |

|timeToLive |net.idlestate.gradle.caching.redis.ttl |14400 (10 days in minutes)

|===

Usage

There are multiple ways to use the Redis based build cache inside your projects.

As plugin in settings.gradle

.settings.gradle

[source,groovy]

buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' } }

dependencies {
    classpath 'gradle.plugin.net.idlestate:gradle-redis-build-cache:1.2.1'
}

}

apply plugin: 'net.idlestate.gradle-redis-build-cache'

buildCache { local { enabled = false }

}

Manual registration in settings.gradle

.settings.gradle

[source,groovy]

buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' } }

dependencies {
    classpath 'gradle.plugin.net.idlestate:gradle-redis-build-cache:1.2.1'
}

}

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
}

}

Using an init script

.init-build-cache.gradle

[source,groovy]

initscript { repositories { maven { url 'https://plugins.gradle.org/m2/' } }

dependencies {
    classpath 'gradle.plugin.net.idlestate:gradle-redis-build-cache:1.2.1'
}

}

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

Statistic

The plugin tracks some values to analyse the cache utilisation and adjust the cache and redis settings.

[cols="1,1,2a"] |=== |Purpose |Redis key format |Values

|Daily usage |statistic_YYYY-MM-DD | [cols="1,1"] !===

!hits !total hits on given date

!misses !total misses on given date

!key_KEY_hits !hits for KEY on given date

!key_KEY_misses !misses for KEY on given date

!===

|Key specific usage |key_statistic_KEY | [cols="1,1"] !===

!hits !total hits for KEY

!misses !total misses for KEY

!begin !timestamp of last cache miss

!end !timestamp of last cache storage

!duration !duration for calculation of cached value

!size !size of cached value

|===

License

include::LICENSE[]

Support Me
Apps
About Me
Google+: Trinea trinea
GitHub: Trinea