11.1 Cache
(require pollen/cache) | package: pollen |
The slowest part of a render is parsing and decoding the source file. Often, previewing a single source file necessarily means decoding others (for instance templates, or other source files that are linked into the main source file). But usually, only one source file is changing at a time. Therefore, Pollen stores copies of the exports of source files — namely, whatever is stored in doc and metas — in the cache so they can be reused.
The cache is a hash table that uses the complete path of a source file as its keys. The value associated with each of these keys is a subcache — another hash table with keys 'doc, 'metas (for storing the exports of the source file) and 'mod-time (for storing the modification time, provided by file-or-directory-modify-seconds).
procedure
(cached-require source-path key) → (or/c txexpr? hash? integer?)
source-path : pathish? key : (or/c 'doc 'metas 'mod-time)
The only keys supported are 'doc, 'metas, and 'mod-time.
If you want the speed benefit of the cache, you should always use cached-require to get data from Pollen source files. That doesn’t mean you can’t still use functions like require, local-require, and dynamic-require. They’ll just be slower.
procedure
(make-cache) → hash?
procedure
(reset-cache) → void?
procedure
(cache-ref source-path) → hash?
source-path : pathish?