The input parameters that you called the function with
The value of any external variable used in the function
The body of the function
The body of any function used inside the cached function
And the value is a tuple of:
The cached output
A hash of the cached output (you'll see why soon)
For both the key and the output hash, Streamlit uses a specialized hash function that knows how to traverse code, hash special objects, and can have its behavior customized by the user.
For example, when the function expensive_computation(a, b), decorated with @st.cache, is executed with a=2 and b=21, Streamlit does the following:
Computes the cache key
If the key is found in the cache, then:
Extracts the previously-cached (output, output_hash) tuple.
Performs an Output Mutation Check, where a fresh hash of the output is computed and compared to the stored output_hash.
