Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Added remove method for invalidate a cached call. Closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
iagocanalejas committed Jan 12, 2017
1 parent 75ac83f commit ecaad1a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# NEXT
- Added `remove` method for invalidate a cached call.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ dependencies {
retrofitBuilder.addCallAdapterFactory(new CachedCallFactory(mCache));
```
4. Use it as normal retrofit. Just remember to use `CachedCall`. All retrofit methods are included, and you can also call `refresh(callback)` to avoid looking in the cache.
4. Use it as normal retrofit. Just remember to use `CachedCall`. All retrofit methods are included, and you can also call `refresh(callback)` to avoid looking in the cache or `remove()` to invalidate a cached call.
```java
CachedCall<MyObject> call = ...
call.refresh(new Callback<MyObject>() {
...
});
call.remove();
```
# Pull Requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ public Response<T> execute() throws IOException {
return mCall.execute();
}

@Override
public void remove() {
mCachingSystem.remove(ResponseUtils.urlToKey(mCall.request().url()));
}

@Override
public void cancel() {
mCall.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ public interface CachedCall<T> extends Call<T>, Cloneable {
*/
Type responseType();

/**
* Remove a cached call if exists
*/
void remove();

}

0 comments on commit ecaad1a

Please sign in to comment.