[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/5] url-cache: add url-cache-expire-time
From: |
Julien Danjou |
Subject: |
[PATCH 5/5] url-cache: add url-cache-expire-time |
Date: |
Wed, 15 Sep 2010 10:51:28 +0200 |
Signed-off-by: Julien Danjou <address@hidden>
---
lisp/url/ChangeLog | 3 ++-
lisp/url/url-cache.el | 7 ++++---
lisp/url/url-vars.el | 5 +++++
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 34169a8..08d9d58 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,7 +1,8 @@
2010-09-14 Julien Danjou <address@hidden>
* url-cache (url-store-in-cache): Make `buff' argument really optional.
- (url-cache-expired): Handle any type of cached object.
+ (url-cache-expired): Handle any type of cached object and add a
+ global `url-cache-expire-time' variable.
(url-fetch-from-cache): Add new function.
(url-is-cached): Enhance docstring.
* url-vars.el: Remove useless variable `url-cache-expired'.
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 3c11a85..36fbded 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -187,8 +187,9 @@ Very fast if you have an `md5' primitive function, suitably
fast otherwise."
(insert-file-contents-literally fnam))
;;;###autoload
-(defun url-cache-expired (url expire-time)
- "Return t if a cached URL is more than EXPIRE-TIME old."
+(defun url-cache-expired (url &optional expire-time)
+ "Return t if a cached URL is more than EXPIRE-TIME old.
+If EXPIRE-TIME is not set, `url-cache-expire-time' is used instead."
(cond (url-standalone-mode
(not (file-exists-p (url-cache-create-filename url))))
(t (let ((cache-time (url-is-cached url)))
@@ -196,7 +197,7 @@ Very fast if you have an `md5' primitive function, suitably
fast otherwise."
(time-less-p
(time-add
(url-is-cached url)
- (seconds-to-time expire-time))
+ (seconds-to-time (or expire-time url-cache-expire-time))
(current-time))
t)))))
diff --git a/lisp/url/url-vars.el b/lisp/url/url-vars.el
index 06d3c2d..2922843 100644
--- a/lisp/url/url-vars.el
+++ b/lisp/url/url-vars.el
@@ -83,6 +83,11 @@ If non-nil and not t, the user will be asked for each
refresh request."
:type 'boolean
:group 'url-cache)
+(defcustom url-cache-expire-time 3600
+ "Maximum time in seconds to keep the documents cached."
+ :type 'integer
+ :group 'url-cache)
+
(defconst url-bug-address "address@hidden"
"Where to send bug reports.")
--
1.7.1
- Enhance url-cache, Julien Danjou, 2010/09/15
- [PATCH 4/5] url-vars.el: Remove useless variable `url-cache-expired'., Julien Danjou, 2010/09/15
- [PATCH 2/5] url-cache.el: (url-fetch-from-cache): Add new function, Julien Danjou, 2010/09/15
- [PATCH 5/5] url-cache: add url-cache-expire-time,
Julien Danjou <=
- [PATCH 1/5] url-cache.el (url-cache-expired): Handle any type of cached object, Julien Danjou, 2010/09/15
- [PATCH 3/5] url-cache.el: (url-is-cached): Enhance docstring., Julien Danjou, 2010/09/15
- Re: Enhance url-cache, Julien Danjou, 2010/09/22