/*
 * Copyright 2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.api.internal.tasks.cache;

import java.io.IOException;

/**
 * Cache protocol interface to be implemented by task output cache backends.
 */
public interface TaskOutputCache {
    /**
     * Load the cached task output corresponding to the given task cache key. The {@code reader} will be called if an entry is found in the cache.
     * @param key the cache key.
     * @param reader the reader to read the data corresponding to the cache key.
     * @return {@code true} if an entry was found, {@code false} otherwise.
     * @throws IOException if an I/O error occurs.
     */
    boolean load(TaskCacheKey key, TaskOutputReader reader) throws IOException;

    /**
     * Store the task output with the given cache key. The {@code writer} will be called to actually write the data.
     * @param key the cache key.
     * @param writer the writer to write the data corresponding to the cache key.
     * @throws IOException if an I/O error occurs.
     */
    void store(TaskCacheKey key, TaskOutputWriter output) throws IOException;

    /**
     * Returns a description for the cache.
     */
    String getDescription();
}

@@ -656,16 +656,42 @@
 cache;%0A%0A
+import java.io.Closeable;%0A
 import j
@@ -710,16 +710,16 @@
 eption;%0A
-
 %0A/**%0A * 
@@ -829,16 +829,34 @@
 utCache 
+extends Closeable 
 %7B%0A    /*
@@ -1000,24 +1000,31 @@
  the cache.%0A
+     *%0A
      * @para
@@ -1466,16 +1466,23 @@
 e data.%0A
+     *%0A
      * @
@@ -1782,24 +1782,24 @@
 he.%0A     */%0A
-
     String g
@@ -1814,11 +1814,213 @@
 ption();
+%0A%0A    /**%0A     * Clean up any resources held by the cache once it's not used anymore.%0A     *%0A     * @throws IOException if an I/O error occurs.%0A     */%0A    @Override%0A    void close() throws IOException;
 %0A%7D%0A

Make `TaskOutputCache` `Closeable` by default