<< Back to previous view

[CLJ-804] Expose memoization cache and original as metadata on memoized functions. Created: 01/Jun/11  Updated: 21/Jun/11  Resolved: 21/Jun/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Trivial
Reporter: Phil Hagelberg Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File 0001-Add-metadata-to-memoized-functions.patch    
Patch: Code


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

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

Comment by Stuart Halloway [ 20/Jun/11 6:51 AM ]

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.

Comment by Fogus [ 20/Jun/11 8:17 AM ]

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

Comment by Phil Hagelberg [ 20/Jun/11 12:18 PM ]

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".

Comment by Christopher Redinger [ 21/Jun/11 6:04 PM ]

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
Generated at Mon Jan 21 02:11:51 CST 2019 using JIRA 4.4#649-r158309.