API Documentation
SerializationCache{T}(path::AbstractString; in_memory_limit,
file_limit, file_gc_ratio)Return a SerializationCache instance that holds elements of type T.
A SerializationCache (along with fetch! and put!) implements a simple two-stage cache that is useful for caching objects that take significantly longer to compute from scratch than to (de)serialize from disk.
Recently fetched objects are cached within an in-memory data structure, while less recently fetched objects are (de)serialized to/from the filesystem via Julia's Serialization module. Specifically, if adding an object to the in-memory cache would cause the in-memory cache to grow beyond in_memory_limit elements, the least recently fetched object in the cache is serialized to a .jls file in path. Once the number of .jls files in path exceeds file_limit, less recently deserialized files are deleted to clear space; the actual ratio of files that are deleted during this "garbage collection" process is determined by file_gc_ratio.
Note that all .jls files in path at the time of SerializationCache construction are considered to be part of constructed cache.
SerializationCaches.fetch! — Function.fetch!(f, cache::SerializationCache, key::AbstractString)Return the object stored at key in cache. If key doesn't exist cache, set key to f() and return the result.
Note that key must be a valid file name.
As part of fetching the requested result, this function performs several bookkeeping operations to maintain cache within its configured limits; see SerializationCache for details.
Base.put! — Function.put!(cache::SerializationCache, key::AbstractString, item;
directly_to_file::Bool=false)Store item in cache at key and return item.
If directly_to_file == true, item is directly serialized to the cache's filesystem layer, skipping the cache's in-memory layer.
Note that key must be a valid file name.