### Install MemoizedSerialization Package Source: https://github.com/raphasampaio/memoizedserialization.jl/blob/main/README.md This snippet shows the command to add the MemoizedSerialization package to a Julia environment using the package manager. ```julia julia> ] add MemoizedSerialization ``` -------------------------------- ### Memoize Function Calls with @memoized_serialization Source: https://github.com/raphasampaio/memoizedserialization.jl/blob/main/README.md Demonstrates how to use the @memoized_serialization macro to cache function results. The first call computes and serializes the result, subsequent calls with the same key load the result from the cache. ```julia using MemoizedSerialization function sum(a, b) println("Computing sum($a, $b)") return a + b end # first call with (1, 2) - computation is performed and result is serialized a, b = 1, 2 result = @memoized_serialization "sum-$a-$b" sum(a, b) # second call with (2, 2) - computation is performed and result is serialized a, b = 2, 2 result = @memoized_serialization "sum-$a-$b" sum(a, b) # third call with (1, 2) - result is loaded from cache (deserialized) a, b = 1, 2 result = @memoized_serialization "sum-$a-$b" sum(a, b) ``` -------------------------------- ### Memoize Function Calls with LRU Cache using @memoized_lru Source: https://github.com/raphasampaio/memoizedserialization.jl/blob/main/README.md Illustrates the usage of the @memoized_lru macro for memoizing function results with a Least Recently Used (LRU) cache strategy. Similar to @memoized_serialization, it caches results but manages cache size. ```julia using MemoizedSerialization function sum(a, b) println("Computing sum($a, $b)") return a + b end # first call with (1, 2) - computation is performed and result is serialized a, b = 1, 2 result = @memoized_lru "sum-$a-$b" sum(a, b) # second call with (2, 2) - computation is performed and result is serialized a, b = 2, 2 result = @memoized_lru "sum-$a-$b" sum(a, b) # third call with (1, 2) - result is loaded from cache (deserialized) a, b = 1, 2 result = @memoized_lru "sum-$a-$b" sum(a, b) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.