Issue 19859 - std.functional.memoize: Ability to clear the cache
Summary: std.functional.memoize: Ability to clear the cache
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-11 08:51 UTC by Aurelien Fredouelle
Modified: 2024-12-01 16:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Aurelien Fredouelle 2019-05-11 08:51:53 UTC
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 Aurelien Fredouelle 2019-05-12 12:01:54 UTC
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 dlangBugzillaToGithub 2024-12-01 16:34:59 UTC
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