diff --git a/doc/guix.texi b/doc/guix.texi index eda4084e7f..ddd98a5fd4 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -39670,6 +39670,14 @@ days, @code{1m} means 1 month, and so on. This allows the user's Guix to keep substitute information in cache for @var{ttl}. +@item @code{new-ttl} (default: @code{#f}) +If specified, this will override the @code{ttl} setting when used for +the @code{Cache-Control} headers, but this value will be used when +scheduling the removal of nars. + +Use this setting when the TTL is being reduced to avoid removing nars +while clients still have cached narinfos. + @item @code{negative-ttl} (default: @code{#f}) Similarly produce @code{Cache-Control} HTTP headers to advertise the time-to-live (TTL) of @emph{negative} lookups---missing store items, for @@ -39719,6 +39727,21 @@ in /var/cache/nar-herder/nar/TYPE. @item @code{directory-max-size} (default: @code{#f}) Maximum size in bytes of the directory. +@item @code{unused-removal-duration} (default: @code{#f}) +If a cached nar isn't used for @code{unused-removal-duration}, it will +be scheduled for removal. + +@var{unused-removal-duration} must denote a duration: @code{5d} means 5 +days, @code{1m} means 1 month, and so on. + +@item @code{ttl} (default: @code{#f}) +If specified this overrides the @code{ttl} used for narinfos when this +cached compression is available. + +@item @code{new-ttl} (default: @code{#f}) +As with the @code{new-ttl} option for @code{nar-herder-configuration}, +this value will override the @code{ttl} when used for narinfo requests. + @end table @end deftp diff --git a/gnu/services/guix.scm b/gnu/services/guix.scm index c438da531c..8b326d9124 100644 --- a/gnu/services/guix.scm +++ b/gnu/services/guix.scm @@ -719,6 +719,8 @@ (define-record-type* (default '())) (ttl nar-herder-configuration-ttl (default #f)) + (new-ttl nar-herder-configuration-new-ttl + (default #f)) (negative-ttl nar-herder-configuration-negative-ttl (default #f)) (log-level nar-herder-configuration-log-level @@ -750,14 +752,22 @@ (define-record-type* (default #f)) (directory-max-size nar-herder-cached-compression-configuration-directory-max-size - (default #f))) + (default #f)) + (unused-removal-duration + nar-herder-cached-compression-configuration-unused-removal-duration + (default #f)) + (ttl nar-herder-cached-compression-configuration-ttl + (default #f)) + (new-ttl nar-herder-cached-compression-configuration-new-ttl + (default #f))) (define (nar-herder-shepherd-services config) (define (cached-compression-configuration->options cached-compression) (match-record cached-compression - (type level directory directory-max-size) + (type level directory directory-max-size + unused-removal-duration ttl new-ttl) `(,(simple-format #f "--enable-cached-compression=~A~A" type @@ -775,6 +785,27 @@ (define (cached-compression-configuration->options cached-compression) (simple-format #f "--cached-compression-directory-max-size=~A=~A" type directory-max-size)) + '()) + ,@(if unused-removal-duration + (list + (simple-format + #f "--cached-compression-unused-removal-duration=~A=~A" + type + unused-removal-duration)) + '()) + ,@(if ttl + (list + (simple-format + #f "--cached-compression-ttl=~A=~A" + type + ttl)) + '()) + ,@(if new-ttl + (list + (simple-format + #f "--cached-compression-new-ttl=~A=~A" + type + new-ttl)) '())))) (match-record config @@ -783,7 +814,7 @@ (define (cached-compression-configuration->options cached-compression) database database-dump host port storage storage-limit storage-nar-removal-criteria - ttl negative-ttl log-level + ttl new-ttl negative-ttl log-level cached-compressions cached-compression-min-uses cached-compression-workers cached-compression-nar-source extra-environment-variables) @@ -825,6 +856,9 @@ (define (cached-compression-configuration->options cached-compression) #$@(if ttl (list (string-append "--ttl=" ttl)) '()) + #$@(if new-ttl + (list (string-append "--new-ttl=" new-ttl)) + '()) #$@(if negative-ttl (list (string-append "--negative-ttl=" negative-ttl)) '())