Skip to content

[Feature Request] Set cacheLife per request? #394

@bendcarmen

Description

@bendcarmen

Hello and thank you for this wonderful library, I have a question/suggestion...is it possible to set different cacheLife values for different responseIds? If not would it make sense to do something like that?

useGet("url-1", {
cacheLife: 60000
});

useGet("url-2", {
cacheLife: 1000
});

I appreciate your time, I was not seeing the ability to do that currently...it seemed like cacheLife would be "overwritten" for "url-1", to 1000 but I might be totally misunderstanding what is happening?

Here is an example where I am using useGet in 2 instances...in one I am setting a cacheLife of 60000ms to fetch a Kanye quote, in the other I am fetching a fake name to attribute the quote to and am setting the cacheLife to 1000ms....and it seems that both are using the 1000ms cacheLife:

https://codesandbox.io/p/sandbox/crazy-resonance-2nv6yn?file=%2Fsrc%2FApp.js

I appreciate any help/guidance on this...thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions