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

Add request cache policy #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add request cache policy #24

wants to merge 2 commits into from

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

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant