groovyClosure Memoize Methods


Syntax

  • closure.memoize()
  • closure.memoizeAtMost(n)
  • closure.memoizeAtLeast(n)
  • closure.memoizeBetween(n, m)

Remarks

Memoization is a method of caching the result of a closure invocation. The memoize function applied to a closure returns a new closure whose return value is cached according to its input parameters. The caches used for the three tweaked variants of memoization methods are LRU caches, that is the least recently used element is removed from the cache first.