Sharing cache between single objects vs group of objects
I have two endpoints that I can use to fetch a resource, once will return an array todo[] and the other will return a single todo by id.
I have two different keys:
['todos'] // to fetch all
['todo', id] // to fetch a specific Foo
What's the best pattern to reconcile the two?
When I call the todo.id one I'd like to update the todos and viceversa. Furthermore, I'd like to reuse data existing in todos as a stale-while-revalidate initial value.
Are we correct in using two separate caches and trying to keep them aligned or is there something else for this use case?
I have two different keys:
['todos'] // to fetch all
['todo', id] // to fetch a specific Foo
What's the best pattern to reconcile the two?
When I call the todo.id one I'd like to update the todos and viceversa. Furthermore, I'd like to reuse data existing in todos as a stale-while-revalidate initial value.
Are we correct in using two separate caches and trying to keep them aligned or is there something else for this use case?