Create

You can use sub eviction-based-cache for creation the new cache.
Arguments are:

:&loader! where .signature ~~ :(:$key) - sub with signature like (:$key).
The sub will be used for producing the new values. Obligatory argument.

:&removal-listener where .signature ~~ :(:$key, :$value, :$cause) -
sub with signature like (:$key, :$value, :$cause).
The sub will be called in case when value removed from the cache.
Cause is element of enum RemoveCause.

:$expire-after-write - how long the cache have to store value after its last re/write

:$expire-after-access - how long the cache have to store value after its last access (read or write)

invalidate

invalidateAll(List:D @keys)

invalidateAll

The value will be removed and removal-listener will be called for each
old values cause Explicit.

elems

Return keys and values stored in cache as Hash.

$cache.elems();

hash

Return keys and values stored in cache as Hash.

$cache.hash();

This is a copy of values. Any modification of returned cache will no have
an effect on values in the store.

clean-up

Clean evicted values from cache.

$cache.clean-up();

This method may be invoked directly by user.

The method invoked on each write operation and ones for several read operation
if there was no write operation recently.

It means that evicted values will not be removed on just in time of its eviction.
This is done for the purpose of optimisation - is it not requires special thread
for checking an eviction. If it is issue for you then you can call it method yourself
by some scheduled Promise for example.