-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract http cache as standalone submodule
Extract http cache support as separate artifact Part of #570
- Loading branch information
Showing
46 changed files
with
269 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
82 changes: 82 additions & 0 deletions
82
apollo-api/src/main/java/com/apollographql/apollo/api/cache/http/HttpCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.apollographql.apollo.api.cache.http; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import okhttp3.Interceptor; | ||
import okhttp3.Response; | ||
|
||
/** | ||
* Http GraphQL http request / response cache. | ||
*/ | ||
public interface HttpCache { | ||
/** | ||
* Cache key http header | ||
*/ | ||
String CACHE_KEY_HEADER = "X-APOLLO-CACHE-KEY"; | ||
/** | ||
* Cache fetch strategy http header | ||
*/ | ||
String CACHE_FETCH_STRATEGY_HEADER = "X-APOLLO-CACHE-FETCH-STRATEGY"; | ||
/** | ||
* Request served Date/time http header | ||
*/ | ||
String CACHE_SERVED_DATE_HEADER = "X-APOLLO-SERVED-DATE"; | ||
/** | ||
* Prefetch response only flag http header | ||
*/ | ||
String CACHE_PREFETCH_HEADER = "X-APOLLO-PREFETCH"; | ||
/** | ||
* Cached response expiration timeout http header | ||
*/ | ||
String CACHE_EXPIRE_TIMEOUT_HEADER = "X-APOLLO-EXPIRE-TIMEOUT"; | ||
/** | ||
* Expire cached response flag http header | ||
*/ | ||
String CACHE_EXPIRE_AFTER_READ_HEADER = "X-APOLLO-EXPIRE-AFTER-READ"; | ||
|
||
/** | ||
* Clear cached http responses | ||
*/ | ||
void clear(); | ||
|
||
/** | ||
* Remove cached http response by key. May throw {@link IOException} | ||
* | ||
* @param cacheKey key of cached response to be removed | ||
*/ | ||
void remove(@Nonnull String cacheKey) throws IOException; | ||
|
||
/** | ||
* Remove cached http response by key and suppress any exception | ||
* | ||
* @param cacheKey key of cached response to be removed | ||
*/ | ||
void removeQuietly(@Nonnull String cacheKey); | ||
|
||
/** | ||
* Read cached http response by key | ||
* | ||
* @param cacheKey key of cached response to be read | ||
* @return cached response | ||
*/ | ||
Response read(@Nonnull String cacheKey); | ||
|
||
/** | ||
* Read and remove cached http response by key if {@code expireAfterRead == true} | ||
* | ||
* @param cacheKey key of cached response to be read | ||
* @param expireAfterRead if {@code true} cached response will be removed after first read | ||
* @return cached response | ||
*/ | ||
Response read(@Nonnull String cacheKey, boolean expireAfterRead); | ||
|
||
/** | ||
* Provide http cache interceptor to be injected into {@link okhttp3.OkHttpClient#interceptors}. Provided interceptor | ||
* must intercept request and serve cached http response as well as store network response to the http cache store. | ||
* | ||
* @return {@link Interceptor} | ||
*/ | ||
Interceptor interceptor(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ql/apollo/cache/http/HttpCacheRecord.java → ...pollo/api/cache/http/HttpCacheRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...llo/cache/http/HttpCacheRecordEditor.java → ...api/cache/http/HttpCacheRecordEditor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...hql/apollo/cache/http/HttpCacheStore.java → ...apollo/api/cache/http/HttpCacheStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ql/apollo/internal/util/ApolloLogger.java → ...graphql/apollo/internal/ApolloLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apply plugin: 'java' | ||
|
||
targetCompatibility = JavaVersion.VERSION_1_7 | ||
sourceCompatibility = JavaVersion.VERSION_1_7 | ||
|
||
dependencies { | ||
compile dep.jsr305 | ||
compile dep.okHttp | ||
|
||
compile project(":apollo-api") | ||
|
||
testCompile dep.junit | ||
testCompile dep.truth | ||
} | ||
|
||
apply from: rootProject.file('gradle/gradle-mvn-push.gradle') | ||
|
||
javadoc { | ||
options.encoding = 'UTF-8' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
POM_ARTIFACT_ID=apollo-http-cache | ||
POM_NAME=Apollo GraphQL http cache support | ||
POM_DESCRIPTION=Apollo GraphQL http cache support | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...llo/cache/http/DiskLruHttpCacheStore.java → ...llo/cache/http/DiskLruHttpCacheStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.