Bug 19859 – std.functional.memoize: Ability to clear the cache

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-05-11T08:51:53Z
Last change time
2024-12-01T16:34:59Z
Assigned to
No Owner
Creator
Aurelien Fredouelle
Moved to GitHub: phobos#10371 →

Comments

Comment #0 by aurelien.fredouelle+dlang — 2019-05-11T08:51:53Z
Other common implementations of memoize usually allow to reset the cache. For example, this is quite common in python: @memoize def square (x): return x*x square(2) square(3) square.cache.clear() It would be helpful if we could accomplish the same with std.functional.memoize.
Comment #1 by aurelien.fredouelle+dlang — 2019-05-12T12:01:54Z
Just tried implementing this by making memoize a struct with a static opCall: https://github.com/dlang/phobos/compare/master...AurelC2G:19859-memoize-cache-clear However I ran into bug #18289, so this doesn't work as-is. Any suggestions?
Comment #2 by robert.schadek — 2024-12-01T16:34:59Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10371 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB