If the two hashes are different, shows a Cached Object Mutated warning. (Note: Setting allow_output_mutation=True disables this step).
If the input key is not found in the cache, then:
Executes the cached function (i.e. output = expensive_computation(2, 21)).
Calculates the output_hash from the function's output.
Stores key → (output, output_hash) in the cache.
Returns the output.
If an error is encountered an exception is raised. If the error occurs while hashing either the key or the output an UnhashableTypeError error is thrown. If you run into any issues, see fixing caching issues.
The hash_funcs parameter
As described above, Streamlit's caching functionality relies on hashing to calculate the key for cached objects, and to detect unexpected mutations in the cached result.
For added expressive power, Streamlit lets you override this hashing process using the hash_funcs argument. Suppose you define a type called FileReference which points to a file in the filesystem:
