+(defun password-read-and-add (prompt &optional key)
+ "Read password, for use with KEY, from user, or from cache if wanted.
+Then store the password in the cache. Uses `password-read' and
+`password-cache-add'.
+Custom variables `password-cache' and `password-cache-expiry'
+regulate cache behavior."
+ (let ((password (password-read prompt key)))
+ (when (and password key)
+ (password-cache-add key password))
+ password))
+