1/* 2 * Copyright (C) 2013 Square, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package com.squareup.okhttp.internal; 17 18import com.squareup.okhttp.Request; 19import com.squareup.okhttp.Response; 20import com.squareup.okhttp.internal.http.CacheRequest; 21import com.squareup.okhttp.internal.http.CacheStrategy; 22import java.io.IOException; 23 24/** 25 * OkHttp's internal cache interface. Applications shouldn't implement this: 26 * instead use {@link com.squareup.okhttp.Cache}. 27 */ 28public interface InternalCache { 29 Response get(Request request) throws IOException; 30 31 CacheRequest put(Response response) throws IOException; 32 33 /** 34 * Remove any cache entries for the supplied {@code request}. This is invoked 35 * when the client invalidates the cache, such as when making POST requests. 36 */ 37 void remove(Request request) throws IOException; 38 39 /** 40 * Handles a conditional request hit by updating the stored cache response 41 * with the headers from {@code network}. The cached response body is not 42 * updated. If the stored response has changed since {@code cached} was 43 * returned, this does nothing. 44 */ 45 void update(Response cached, Response network) throws IOException; 46 47 /** Track an conditional GET that was satisfied by this cache. */ 48 void trackConditionalCacheHit(); 49 50 /** Track an HTTP response being satisfied with {@code cacheStrategy}. */ 51 void trackResponse(CacheStrategy cacheStrategy); 52} 53