store: Add 'references/cached'.
* guix/store.scm (references/cached): New procedure.master
parent
25af35fa32
commit
c70cf1a724
|
@ -135,6 +135,7 @@
|
||||||
|
|
||||||
built-in-builders
|
built-in-builders
|
||||||
references
|
references
|
||||||
|
references/cached
|
||||||
references/substitutes
|
references/substitutes
|
||||||
references*
|
references*
|
||||||
query-path-info*
|
query-path-info*
|
||||||
|
@ -1393,6 +1394,13 @@ error if there is no such root."
|
||||||
;; would use a cache associated with the daemon connection instead (XXX).
|
;; would use a cache associated with the daemon connection instead (XXX).
|
||||||
(make-hash-table 100))
|
(make-hash-table 100))
|
||||||
|
|
||||||
|
(define (references/cached store item)
|
||||||
|
"Like 'references', but cache results."
|
||||||
|
(or (hash-ref %reference-cache item)
|
||||||
|
(let ((references (references store item)))
|
||||||
|
(hash-set! %reference-cache item references)
|
||||||
|
references)))
|
||||||
|
|
||||||
(define (references/substitutes store items)
|
(define (references/substitutes store items)
|
||||||
"Return the list of list of references of ITEMS; the result has the same
|
"Return the list of list of references of ITEMS; the result has the same
|
||||||
length as ITEMS. Query substitute information for any item missing from the
|
length as ITEMS. Query substitute information for any item missing from the
|
||||||
|
|
Reference in New Issue