[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp/net tramp-cache.el
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] emacs/lisp/net tramp-cache.el |
Date: |
Thu, 27 Aug 2009 13:50:42 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Michael Albinus <albinus> 09/08/27 13:50:41
Modified files:
lisp/net : tramp-cache.el
Log message:
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
(tramp-cache-inhibit-cache): Extend doc string. It allows also
timestamps.
(tramp-get-file-property): Check for timestamps in
`tramp-cache-inhibit-cache'.
(tramp-set-file-property): Write timestamp.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/net/tramp-cache.el?cvsroot=emacs&r1=1.21&r2=1.22
Patches:
Index: tramp-cache.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/tramp-cache.el,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- tramp-cache.el 2 Aug 2009 17:15:42 -0000 1.21
+++ tramp-cache.el 27 Aug 2009 13:50:41 -0000 1.22
@@ -62,6 +62,7 @@
(autoload 'tramp-file-name-host "tramp")
(autoload 'tramp-file-name-localname "tramp")
(autoload 'tramp-run-real-handler "tramp")
+ (autoload 'tramp-time-less-p "tramp")
(autoload 'time-stamp-string "time-stamp"))
;;; -- Cache --
@@ -70,7 +71,11 @@
"Hash table for remote files properties.")
(defvar tramp-cache-inhibit-cache nil
- "Inhibit cache read access, when non-nil.")
+ "Inhibit cache read access, when `t'.
+`nil' means to accept cache entries unconditionally. If the
+value is a timestamp (as returned by `current-time'), cache
+entries are not used when they have been written before this
+time.")
(defcustom tramp-persistency-file-name
(cond
@@ -106,9 +111,21 @@
(let* ((hash (or (gethash vec tramp-cache-data)
(puthash vec (make-hash-table :test 'equal)
tramp-cache-data)))
- (value (if (and (null tramp-cache-inhibit-cache) (hash-table-p hash))
- (gethash property hash default)
- default)))
+ (value (when (hash-table-p hash) (gethash property hash))))
+ (if
+ ;; We take the value only if there is any, and
+ ;; `tramp-cache-inhibit-cache' indicates that it is still
+ ;; valid. Otherwise, DEFAULT is set.
+ (and (consp value)
+ (or (null tramp-cache-inhibit-cache)
+ (and (consp tramp-cache-inhibit-cache)
+ (tramp-time-less-p
+ tramp-cache-inhibit-cache (car value)))))
+ (setq value (cdr value))
+ (setq value default))
+
+ (if (consp tramp-cache-inhibit-cache)
+ (tramp-message vec 1 "%s %s %s" file property value))
(tramp-message vec 8 "%s %s %s" file property value)
value))
@@ -121,7 +138,8 @@
(let ((hash (or (gethash vec tramp-cache-data)
(puthash vec (make-hash-table :test 'equal)
tramp-cache-data))))
- (puthash property value hash)
+ ;; We put the timestamp there.
+ (puthash property (cons (current-time) value) hash)
(tramp-message vec 8 "%s %s %s" file property value)
value))