NerdWalletOSS / apollo-cache-policies

An extension of the Apollo 3 cache with support for advanced cache policies.
Apache License 2.0
152 stars 22 forks source link

For TTL, is it set at the type level or field level? #66

Open Sumu-Ning opened 1 year ago

Sumu-Ning commented 1 year ago

If I have a type, with fields: id, fieldA and fieldB, assume the TTL is 10 seconds.

Assume I cached fieldA at time 5s, and cached fieldB at time 10s. If I request fieldA again at time 16s, will it hit cache or do a network call?

Thank you!

danReynolds commented 1 year ago

Yea the second write would renew the TTL for the entity so the read wouldn't hit the network

Sumu-Ning commented 1 year ago

Thank you for the quick feedback!

Will it be possible to add the (optional) ttl at the field level? As described before, the data in fieldA might already become stale, even though the whole object gets renewed.

danReynolds commented 1 year ago

Hey! Just got back from vacation. I don't think field level TTLs are going to be supported for now, it should be possible but would be a sizable feature and I'm not planning to take that on at the moment. Thanks for the inquiry!