Simple, filesystem-based caching.
- Pick a directory to store caches in.
By default, it's the
./compiled/with-cache
directory. - Wrap "expensive" computations in a thunk, call the thunk via
with-cache
. - Results of the expensive computation are automatically stored and retrieved.
Example:
(with-cache "fact42.rktd"
(λ () (factorial 42)))
(with-cache "pict.rktd"
(λ () (standard-fish 100 50))
#:read deserialize
#:write serialize)
From the Racket package server:
$ raco pkg install with-cache
From Github:
$ git clone https://github.com/bennn/with-cache
$ raco pkg install ./with-cache
Don't forget the ./
!
The real documentation is here: http://docs.racket-lang.org/with-cache/index.html
and has instructions for:
- invalidating cachefiles
- changing the default cache directory
- cachefile naming conventions