pull/9/head
Matthew Butterick 11 years ago
parent e066829a76
commit 5185c96122

@ -19,6 +19,15 @@
(define (cache-has-key? path)
(hash-has-key? (current-cache) path))
(define (cache path)
(dynamic-rerequire path)
(hash-set! (current-cache) path (make-hash))
(define cache-hash (cache-ref path))
(hash-set! cache-hash 'mod-time (file-or-directory-modify-seconds path))
(hash-set! cache-hash 'main (dynamic-require path 'main))
(hash-set! cache-hash 'metas (dynamic-require path 'metas))
(void))
(define (cached-require path-string key)
(when (not (current-cache)) (error "cached-require: No cache set up."))
@ -27,15 +36,6 @@
(with-handlers ([exn:fail? (λ(exn) (displayln (format "cached-require: ~a is not a valid path" path-string)))])
(->complete-path path-string)))
(define (cache path)
(dynamic-rerequire path)
(hash-set! (current-cache) path (make-hash))
(define cache-hash (cache-ref path))
(hash-set! cache-hash 'mod-time (file-or-directory-modify-seconds path))
(hash-set! cache-hash 'main (dynamic-require path 'main))
(hash-set! cache-hash 'metas (dynamic-require path 'metas))
(void))
(when (or (not (cache-has-key? path))
(> (file-or-directory-modify-seconds path) (hash-ref (cache-ref path) 'mod-time)))
(cache path))

Loading…
Cancel
Save