react-server icon indicating copy to clipboard operation
react-server copied to clipboard

Support customization of "cache affecting data"

Open roblg opened this issue 9 years ago • 2 comments

For context:

https://react-server.slack.com/archives/discussion/p1478769782000401 https://react-server.slack.com/archives/discussion/p1478826404000414

General idea: there are some advanced usages where you might want to customize the key that goes into the request data cache. One is discussed above.

This is potentially a little trickier than it sounds, because we're currently defining equality based on only the fields in _getCacheAffectingData: https://github.com/redfin/react-server/blob/master/packages/react-server/core/ReactServerAgent/Request.js#L257-L266. In the cache, we examine those at https://github.com/redfin/react-server/blob/master/packages/react-server/core/ReactServerAgent/Cache.js#L274-L278

One approach may be to generalize our equality checking, and then provide a builder method on the request chain to either modify or replace the "cache affecting data" object.

roblg avatar Nov 14 '16 19:11 roblg

As this code https://github.com/redfin/react-server/blob/master/packages/react-server/core/ReactServerAgent/Cache.js#L417-L418 states, there is implicit dependency from Cach on Request, even though there is no explicit require/import from each other.

I suppose the "key customization" logic should resides in Cache.

mocheng avatar Nov 15 '16 02:11 mocheng

The cache structure is two level. The first level is indexed by key urlPath according to _findEntry https://github.com/redfin/react-server/blob/master/packages/react-server/core/ReactServerAgent/Cache.js#L401-L412

If cache key is customizable, the _findEntry method should be updated.

mocheng avatar Nov 15 '16 03:11 mocheng