Google News
logo
Hack - Interview Questions
What are the Memoization Options in Hack?
The __Memoize and __MemoizeLSB attributes in Hack support experimental options that control how the function behaves with respect to an Implicit Context value.

The Implicit Context (IC) is an experimental feature. It is a value that can be associated with the execution of code and propagated implicitly from caller to callee in a way that is safe for concurrently running code.

In order to prevent the problem of "memoization cache poisoning" where results computed using one IC value are available to callers using a different IC value, we require that memoized functions executed with an IC value are explicit about how they should behave relative to the IC value. Broadly, functions can specify one of two choices:

* This function's memoization cache key should incorporate the propagated IC value.
* This function's memoization cache key should not incorporate the propagated IC value AND this function and its dependencies cannot depend on the propagated IC value.
Advertisement