hapijs / catbox

Multi-strategy object caching service
Other
494 stars 72 forks source link

getOrGenerate functionality no longer available on a per key basis #110

Closed kpdecker closed 9 years ago

kpdecker commented 9 years ago

After the get and getOrGenerate functionality were merged, it's impossible to provide a per-record generator. For situations where the policy is intended to be a grab bag of data and is not constructed by the consumer, this makes the cache unusable.

hueniverse commented 9 years ago

The issue is not setting the generateFunc per key, but specifying it later, after Policy construction.

hueniverse commented 9 years ago

Closing in favor of #111

candid82 commented 9 years ago

I don't think #111 fixes the issue described here. In our use case we do need to provide custom generateFunc on per key basis. In order to do that using new policy.rules() method introduced in #111, we would have to call it before every policy.get() call, which seems like an extremely bad idea. Besides, to preserve other rules we would have to do something like policy.rules(_.extend(policy.rule, {generateFunc: newFunc})), but policy.rule is not part of public API, and it's not strictly speaking the same as options (there is compile call involved https://github.com/hapijs/catbox/blob/master/lib/policy.js#L34), so we are making unsafe assumptions here.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.