bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49033: 28.0.50; [PATCH] Feature suggestion, url-cache-expiry-alist t


From: Alex Bochannek
Subject: bug#49033: 28.0.50; [PATCH] Feature suggestion, url-cache-expiry-alist to override expire time for cache pruning
Date: Sat, 19 Jun 2021 12:24:00 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin)

Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net> writes:

> Hi Alex,
>
>>>> -                 ;; Twelve hours.
>>>> -                 (* 12 60 60))))
>>>> +                 gravatar-cache-ttl)))
>
>> Lars Ingebrigtsen <larsi@gnus.org> writes:
>>> I don't mind that -- but is this really something that somebody would
>>> want to control?  It just seemed unlikely to me.
>
> Alex Bochannek writes:
>> I tend to find it difficult to reason about functionality if constants
>> like this are in the code and not in variables.
>
> Maybe use defconst instead?
>
> Just a drive-by thought,
> benny

I like that idea, that seems like a good compromise.

Thanks!
diff --git a/lisp/image/gravatar.el b/lisp/image/gravatar.el
index f6f056a2ba..ebae356e26 100644
--- a/lisp/image/gravatar.el
+++ b/lisp/image/gravatar.el
@@ -51,6 +51,9 @@ gravatar-cache-ttl
   :group 'gravatar)
 (make-obsolete-variable 'gravatar-cache-ttl nil "28.1")

+(defconst gravatar-cache-expiry (* 12 60 60)
+  "Time to live for gravatar cache entries (12 hours.)")
+
 (defcustom gravatar-rating "g"
   "Most explicit Gravatar rating level to allow.
 Some gravatars are rated according to how suitable they are for
@@ -287,8 +290,7 @@ gravatar-retrieve
 (defun gravatar--prune-cache ()
   (let ((expired nil)
         (time (- (time-convert (current-time) 'integer)
-                 ;; Twelve hours.
-                 (* 12 60 60))))
+                 gravatar-cache-expiry)))
     (maphash (lambda (key val)
                (when (< (car val) time)
                  (push key expired)))
-- 
Alex.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]