cacheToolsRequire

Looks up key; if it exists returns corresponding value else evaluates value, adds it to the associative array and returns it.

V
cacheToolsRequire
(
CT
K
V
)
(
CT aa
,
K key
,
lazy V value = V.init
)
if (
is(CT == class) &&
!is(CT == V[K])
)

Parameters

aa CT

The cache.

key K

The key.

value V

The required value.

Return Value

Type: V

The value.

Examples

auto cache = CacheLRU!(int,string);
cache.require(5, { return "5"; }());

Meta