Hi everyone,
A small request about the cached trait for functions that makes them
memoized: would it be possible to make it parametric?
I think it would be nice to have at least one variant
sub foo is cached(max=>$size)
caching just the first $size results.
Maybe it could also be useful to have a default size of the cache
instead of letting it grow indefinitely? I can easily imagine RAMs
suffering because someone used "is cached" in a bad place :)
Also it would be quite useful, I think, to have another variant:
sub foo is cached(using => $mapping)
this way people could implement their own caching policies easily, i.e.
FIFO buffer, most used, most expensive and so on. Or reload on-disk
caches from run to run, and even the other suggestion could be
implemented easily in terms of this.
On the other hand, if the cached trait had a %.mapping attribute
possible we could do this withouth making cached parametric, I mean:
sub foo is cached {...}
&foo.mapping = $my_mapping
but I think the other way it would be more clear.