diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-21 16:11:34 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-21 16:11:34 +0000 |
commit | 10f60197d60f02245d5bd30cc6abb62199e6244d (patch) | |
tree | 047d50c43ba2923cb69cf44617074a9246e499a1 | |
parent | 1dfd91e7373160854eeb85582598e6c8cc1b3561 (diff) | |
parent | 7fc59f07e565ee1e0696b8ca61b8faa6f480a768 (diff) |
Merge pull request #80 from jleechpe/invalidate-cache
Fix cache invalidation to behave properly.
-rw-r--r-- | sx-cache.el | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sx-cache.el b/sx-cache.el index 9f152e2..7ff7f7f 100644 --- a/sx-cache.el +++ b/sx-cache.el @@ -78,21 +78,26 @@ CACHE is resolved to a file name by `sx-cache-get-file-name'." VARS is a list of variables to unbind to ensure cache is cleared. If INIT-METHOD is defined, call it after all invalidation to re-initialize the cache." - (sx-cache-set cache nil) + (let ((file (sx-cache-get-file-name cache))) + (delete-file file)) (mapc #'makunbound vars) - (funcall init-method)) + (when init-method + (funcall init-method))) (defun sx-cache-invalidate-all (&optional save-auth) "Invalidate all caches using `sx-cache--invalidate'. -Afterwards reinitialize caches using `sx-initialize'. If -SAVE-AUTH is non-nil, do not clear AUTH cache." - (let ((caches (let ((default-directory sx-cache-directory)) - (file-expand-wildcards "*.el")))) +Afterwards reinitialize caches using `sx-initialize'. If +SAVE-AUTH is non-nil, do not clear AUTH cache. + +Note: This will also remove read/unread status of questions as well +as delete the list of hidden questions." + (let* ((default-directory sx-cache-directory) + (caches (file-expand-wildcards "*.el"))) (when save-auth (setq caches (cl-remove-if (lambda (x) - (string= x "auth.el")) caches))) + (string= x "auth.el")) caches))) (lwarn 'stack-mode :debug "Invalidating: %S" caches) - (mapc #'sx-cache--invalidate caches) + (mapc #'delete-file caches) (sx-initialize 'force))) (provide 'sx-cache) |