BuildCacheService (Gradle API 4.10.1)
Date: 2018-09-12

org.gradle.caching

## Interface BuildCacheService

- All Superinterfaces:
    AutoCloseable, Closeable
  All Known Implementing Classes:
    MapBasedBuildCacheService

      @Incubating
      public interface BuildCacheService
      extends Closeable

  Protocol interface to be implemented by a client to a build cache backend.

  Build cache implementations should report a non-fatal failure as a `BuildCacheException`. Non-fatal failures could include failing to retrieve a cache entry or unsuccessfully completing an upload a new cache entry. Gradle will not fail the build when catching a `BuildCacheException`, but it may disable caching for the build if too many failures occur.

  All other failures will be considered fatal and cause the Gradle build to fail. Fatal failures could include failing to read or write cache entries due to file permissions, authentication or corruption errors.

  Every build cache implementation should define a `BuildCache` configuration and `BuildCacheServiceFactory` factory.

  Since:
    3.5

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Clean up any resources held by the cache once it's not used anymore.
    `boolean` | `load(BuildCacheKey key, BuildCacheEntryReader reader)` Load the cached entry corresponding to the given cache key.
    `void` | `store(BuildCacheKey key, BuildCacheEntryWriter writer)` Store the cache entry with the given cache key.

- - ### Method Detail

    - #### load

          boolean load(BuildCacheKey key,
                       BuildCacheEntryReader reader)
                throws BuildCacheException

      Load the cached entry corresponding to the given cache key. The `reader` will be called if an entry is found in the cache.
      Parameters:
        `key` - the cache key.
        `reader` - the reader to read the data corresponding to the cache key.
      Returns:
        `true` if an entry was found, `false` otherwise.
      Throws:
        `BuildCacheException` - if the cache fails to load a cache entry for the given key

    - #### store

          void store(BuildCacheKey key,
                     BuildCacheEntryWriter writer)
              throws BuildCacheException

      Store the cache entry with the given cache key. The `writer` will be called to actually write the data.
      Parameters:
        `key` - the cache key.
        `writer` - the writer to write the data corresponding to the cache key.
      Throws:
        `BuildCacheException` - if the cache fails to store a cache entry for the given key

    - #### close

          void close()
              throws IOException

      Clean up any resources held by the cache once it's not used anymore.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Closeable`
      Throws:
        `IOException` - if the cache fails to close cleanly.