[gnus git] branch master updated: n0-13-47-g38daba9 =1= Cache empty auth-source-search result sets.

Ted Zlatanov <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  38daba9dc05d445536890276dbff42063bde29d7 (commit)
      from  dc34b73127ae3c4ed396658292b0da583168371f (commit)


- Log -----------------------------------------------------------------
commit 38daba9dc05d445536890276dbff42063bde29d7
Author: Ted Zlatanov <[email protected]>
Date:   Fri Feb 25 15:29:23 2011 -0600

    Cache empty auth-source-search result sets.
    
    * password-cache.el (password-in-cache-p): Convenience function to
    check if a key is in the cache, even if the value is nil.
    
    * auth-source.el (auth-source-search): Cache empty result sets.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 65e391f..44e06a8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
 2011-02-25  Teodor Zlatanov  <[email protected]>
 
+	* auth-source.el (auth-source-search): Cache empty result sets.
+
+	* password-cache.el (password-in-cache-p): Convenience function to
+	check if a key is in the cache, even if the value is nil.
+
 	* auth-source.el (auth-source-save-behavior): New variable to replace
 	`auth-source-never-create'.
 	(auth-source-netrc-create): Use it.
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 80b1398..26e23a7 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -534,10 +534,13 @@ must call it to obtain the actual value."
          (keys (loop for i below (length spec) by 2
                      unless (memq (nth i spec) ignored-keys)
                      collect (nth i spec)))
+         (cached (auth-source-remembered-p spec))
+         ;; note that we may have cached results but found is still nil
+         ;; (there were no results from the search)
          (found (auth-source-recall spec))
          filtered-backends accessor-key backend)
 
-    (if (and found auth-source-do-cache)
+    (if (and cached auth-source-do-cache)
         (auth-source-do-debug
          "auth-source-search: found %d CACHED results matching %S"
          (length found) spec)
@@ -590,7 +593,8 @@ must call it to obtain the actual value."
          "auth-source-search: CREATED %d results (max %d) matching %S"
          (length found) max spec))
 
-      (when (and found auth-source-do-cache)
+      ;; note we remember the lack of result too, if it's applicable
+      (when auth-source-do-cache
         (auth-source-remember spec found)))
 
       found))
@@ -664,6 +668,11 @@ Returns the deleted entries."
   (password-read-from-cache
    (concat auth-source-magic (format "%S" spec))))
 
+(defun auth-source-remembered-p (spec)
+  "Check if SPEC is remembered."
+  (password-in-cache-p
+   (concat auth-source-magic (format "%S" spec))))
+
 (defun auth-source-forget (spec)
   "Forget any cached data matching SPEC exactly.
 
@@ -674,7 +683,10 @@ Returns t or nil for forgotten or not found."
 ;;; (loop for sym being the symbols of password-data when (string-match (concat "^" auth-source-magic) (symbol-name sym)) collect (symbol-name sym))
 
 ;;; (auth-source-remember '(:host "wedd") '(4 5 6))
+;;; (auth-source-remembered-p '(:host "wedd"))
 ;;; (auth-source-remember '(:host "xedd") '(1 2 3))
+;;; (auth-source-remembered-p '(:host "xedd"))
+;;; (auth-source-remembered-p '(:host "zedd"))
 ;;; (auth-source-recall '(:host "xedd"))
 ;;; (auth-source-recall '(:host t))
 ;;; (auth-source-forget+ :host t)
diff --git a/lisp/password-cache.el b/lisp/password-cache.el
index 8738aa6..a7f75a0 100644
--- a/lisp/password-cache.el
+++ b/lisp/password-cache.el
@@ -76,6 +76,12 @@ regulate cache behavior."
        key
        (symbol-value (intern-soft key password-data))))
 
+(defun password-in-cache-p (key)
+  "Check if KEY is in the cache."
+  (and password-cache
+       key
+       (intern-soft key password-data)))
+
 (defun password-read (prompt &optional key)
   "Read password, for use with KEY, from user, or from cache if wanted.
 KEY indicate the purpose of the password, so the cache can

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog         |    5 +++++
 lisp/auth-source.el    |   16 ++++++++++++++--
 lisp/password-cache.el |    6 ++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.