Expose memoization cache and original as metadata on memoized functions.

Description

The attached patch exposes the memoization cache and original pre-memoized value as metadata on memoized functions.

The metadata keys are ::memoize-cache and :rememoized respectively, to which I'm not too attached.

Environment

None

Activity

Show:
Stuart Halloway
June 20, 2011, 10:51 PM

Can you say more about the problems(s) being solved there? Given all the other feature work that has been done/requested around memoization, tempted to let this work happen in a contrib library first. But that is partially because I don't know from this ticket what pain is being addressed.

Fogus
June 21, 2011, 12:17 AM

Unk may provide a starting point for a contrib lib. https://github.com/fogus/unk

import
June 21, 2011, 4:18 AM

I'm in support of a smarter memoize a la unk; this could be considered a stop-gap measure that helps in situations where the current memoize implementation simply cannot be used due to unbounded memory use.

I've also come across circumstances where I can't use memoize because it will make my function untestable, though admittedly these involve memoizing impure functions—perhaps the answer there is just "don't do that".

Christopher Redinger
June 22, 2011, 10:04 AM

Let's do one of the following instead:

  • make unk a contrib (after addressing Rich's questions)

  • recommend Guava for advanced caching

  • make a Guava-wrapping contrib

Declined

Assignee

Unassigned

Reporter

import

Labels

None

Approval

None

Patch

Code

Priority

Trivial