substitute: Delete cached narinfos more than two-month old.
This allows 'guix substitute' to shrink the cache a bit more, which saves space and improves performance of cache-cleanup phases since fewer entries need to be traversed. * guix/scripts/substitute.scm (cached-narinfo-expiration-time): Define 'max-ttl' and use it as an upper bound.
This commit is contained in:
parent
92ee0fd5eb
commit
3f5e141829
1 changed files with 7 additions and 2 deletions
|
@ -167,6 +167,11 @@ was found."
|
||||||
|
|
||||||
(define (cached-narinfo-expiration-time file)
|
(define (cached-narinfo-expiration-time file)
|
||||||
"Return the expiration time for FILE, which is a cached narinfo."
|
"Return the expiration time for FILE, which is a cached narinfo."
|
||||||
|
(define max-ttl
|
||||||
|
;; Upper bound on the TTL used to avoid keeping around cached narinfos for
|
||||||
|
;; too long, which makes the cache bigger and more expensive to traverse.
|
||||||
|
(* 2 30 24 60 60)) ;2 months
|
||||||
|
|
||||||
(catch 'system-error
|
(catch 'system-error
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(call-with-input-file file
|
(call-with-input-file file
|
||||||
|
@ -174,10 +179,10 @@ was found."
|
||||||
(match (read port)
|
(match (read port)
|
||||||
(('narinfo ('version 2) ('cache-uri uri)
|
(('narinfo ('version 2) ('cache-uri uri)
|
||||||
('date date) ('ttl ttl) ('value #f))
|
('date date) ('ttl ttl) ('value #f))
|
||||||
(+ date ttl))
|
(+ date (min ttl max-ttl)))
|
||||||
(('narinfo ('version 2) ('cache-uri uri)
|
(('narinfo ('version 2) ('cache-uri uri)
|
||||||
('date date) ('ttl ttl) ('value value))
|
('date date) ('ttl ttl) ('value value))
|
||||||
(+ date ttl))
|
(+ date (min ttl max-ttl)))
|
||||||
(x
|
(x
|
||||||
0)))))
|
0)))))
|
||||||
(lambda args
|
(lambda args
|
||||||
|
|
Reference in a new issue