All Downloads are FREE. Search and download functionalities are using the official Maven repository.

okhttp3.internal.cache.InternalCache.kt Maven / Gradle / Ivy

/*
 * Copyright (C) 2013 Square, Inc.
 *
 * 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 okhttp3.internal.cache

import okhttp3.Request
import okhttp3.Response
import java.io.IOException

/**
 * OkHttp's internal cache interface. Applications shouldn't implement this: instead use [okhttp3.Cache].
 */
interface InternalCache {

  @Throws(IOException::class)
  fun get(request: Request): Response?

  @Throws(IOException::class)
  fun put(response: Response): CacheRequest?

  /**
   * Remove any cache entries for the supplied [request]. This is invoked when the client
   * invalidates the cache, such as when making POST requests.
   */
  @Throws(IOException::class)
  fun remove(request: Request)

  /**
   * Handles a conditional request hit by updating the stored cache response with the headers from
   * [network]. The cached response body is not updated. If the stored response has changed
   * since [cached] was returned, this does nothing.
   */
  fun update(cached: Response, network: Response)

  /** Track an conditional GET that was satisfied by this cache. */
  fun trackConditionalCacheHit()

  /** Track an HTTP response being satisfied with [cacheStrategy]. */
  fun trackResponse(cacheStrategy: CacheStrategy)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy