buildo / avenger

A CQRS-flavoured data fetching and caching layer in TypeScript. Batching, caching, data-dependencies and manual invalidations in a declarative fashion for Node and the browser
MIT License
59 stars 2 forks source link

invalidate args should be optional #193

Open fes300 opened 5 years ago

fes300 commented 5 years ago

at the moment invalidate API always asks you to specify a unique key of the cache (aka input) to invalidate (unless the type of input is the singleton type, in which case it is inferred automagically). This means that you don't have a way to invalidate a whole Cache, only its single entries. I argue that in the lifecycle of an App session, data is often fetched for just one combination of input and this strictness adds unnecessary boilerplate.

Think of a user query that takes a password and a username, there will always be a unique user in memory and we want to wipe the whole cache when the user logout. It would be nice to be able to wipe the whole Cache without specifying the single key.

The proposal is to always allow empty inputs when invalidating a cache, with the logical addition that no input == whole cache invalidation, which is (probably not by chance) also the logical consequence of invalidating a query that accepts no params.