Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Conversation

@yapryntsev
Copy link

@yapryntsev yapryntsev commented Mar 1, 2021

Idea

Sometimes it is wise not to cache some requests that belong to the same HttpService. It's not possible right now, and as a result, you must create multiply HttpServices with cache hook and without. The idea is that let request decide if the response should be cached.

Solution

Add a new property for the Request protocol, which is then used by the cache hook to determine if the response should be cached. For example:

struct SomeRequest: JsonRequest {
    ...
    var shouldCacheResult: Bool {
        return false
    }
    ...
}

This property will be used in default CachingServiceHook, but you are also free to use this property in your cache-layer implementation

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant