strategies: Strategies for caching items.

Description Usage Arguments Value

Description

The function memo accepts an argument 'key' which specifies the keying strategy.

digest_key computes a key by hashing the contents of the object using the digest package. No attempt is made to avoid MD5 hash collisions.

The pointer_key strategy uses object identity, that is, pointer equivalence. This can be faster because hte entire object need not be hashed. However, this strategy is only useful when the function is called repeatedly on the same object rather than merely identical objects. Also be aware that the cache will hold on to the values of the arguments, to prevent them being garbage collected.

The hybrid_key strategy first tries to key on object identity and then falls back on computing the md5 digest. This may use two cache slots per result.

Usage

1
2
3
4
5
digest_key(fn, cache, digest = digest::digest)

pointer_key(fn, cache)

hybrid_key(fn, cache, digest = digest::digest)

Arguments

fn

A function whose results should be cached.

cache

A cache object.

digest

A digest function to use.

Value

A memoized function.


memo documentation built on May 2, 2019, 7:01 a.m.