org.gradle.caching

## Class MapBasedBuildCache

- java.lang.Object
- - org.gradle.caching.MapBasedBuildCache

- All Implemented Interfaces:
    Closeable, AutoCloseable, BuildCache

      @Incubating
      public class MapBasedBuildCache
      extends Object
      implements BuildCache

  Simple build cache implementation that delegates to a `ConcurrentMap`.
  Since:
    3.3

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MapBasedBuildCache(String description, ConcurrentMap<String,byte[]> delegate)`

  - ### Method Summary

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

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MapBasedBuildCache

          public MapBasedBuildCache(String description,
                            ConcurrentMap<String,byte[]> delegate)

  - ### Method Detail

    - #### getDescription

          public String getDescription()

      Description copied from interface: `BuildCache`
      Returns a description for the cache.
      Specified by:
        `getDescription` in interface `BuildCache`

    - #### load

          public boolean load(BuildCacheKey key,
                     BuildCacheEntryReader reader)
                       throws BuildCacheException

      Description copied from interface: `BuildCache`
      Load the cached entry corresponding to the given cache key. The `reader` will be called if an entry is found in the cache.
      Specified by:
        `load` in interface `BuildCache`
      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

          public void store(BuildCacheKey key,
                   BuildCacheEntryWriter output)
                     throws BuildCacheException

      Description copied from interface: `BuildCache`
      Store the cache entry with the given cache key. The `writer` will be called to actually write the data.
      Specified by:
        `store` in interface `BuildCache`
      Parameters:
        `key` - the cache key.
        `output` - 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

          public void close()
                     throws IOException

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