aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-03-29 01:21:32 +0100
committerLudovic Courtès <ludo@gnu.org>2020-03-29 15:32:17 +0200
commitc70cf1a724fb15e108dc842413db15a0b9f4bc10 (patch)
tree2739f9db7b01b6c0ac8ab7cf773f557703fdf879
parent25af35fa32bf6c991510406a330d4a42bd5beba8 (diff)
downloadguix-c70cf1a724fb15e108dc842413db15a0b9f4bc10.tar
guix-c70cf1a724fb15e108dc842413db15a0b9f4bc10.tar.gz
store: Add 'references/cached'.
* guix/store.scm (references/cached): New procedure.
-rw-r--r--guix/store.scm8
1 files changed, 8 insertions, 0 deletions
diff --git a/guix/store.scm b/guix/store.scm
index b3641ef95d..ca8c0e5ef8 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -135,6 +135,7 @@
built-in-builders
references
+ references/cached
references/substitutes
references*
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).
(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)
"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