StrFnCache
Caches A => F[String]
functions and makes them super-fast by executing once per path,
optimising and caching the result, and then using it as template for all subsequent calls.
"Paths" are independent from each other and are defined by StrFnCacheParam instances. There is typically
one path per sum type, for example Option
has two paths: None
and Some[A]
; String
only has one which is
itself.
Values (once in a path) must be completely opaque and not used to affect function logic or conditionality. For example, a function that takes a name and prints it a few times is fine, but a function which branched according to string length, or converted the string to uppercase would be broken by this cache because the caching logic doesn't branch according to string length, and the caching logic doesn't convert strings to uppercase. You can still have your super-fast cake and eat it too by creating your own customised StrFnCacheParam instance that includes any value modification or branching you need. In such cases it would be wise to cross-compile the logic rather than duplicate it, and/or modify your function (or React component) to accept inputs that have already been processed.
- Since
1.1.0
Type members
Classlikes
A whitelist of routes will be pre-cached, any routes not in the whitelist will return None
.
A whitelist of routes will be pre-cached, any routes not in the whitelist will return None
.