diff options
author | Sean Allred <code@seanallred.com> | 2014-11-18 15:28:30 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2014-11-18 15:28:30 -0500 |
commit | 85268ef6fa01b407e712df8199816f9639a5e539 (patch) | |
tree | 246491413ffd84eee4ba021edae1bf011f432aab | |
parent | 2149a4c2375e9c73c85c7375565affe3212b6710 (diff) | |
parent | 7e3685bf944378c49738de2ee2c685af785806b6 (diff) |
Merge pull request #73 from jleechpe/invalidate-cache
Provide cache invalidation
-rw-r--r-- | sx-cache.el | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sx-cache.el b/sx-cache.el index e3b356b..a564a53 100644 --- a/sx-cache.el +++ b/sx-cache.el @@ -67,6 +67,31 @@ DATA will be written as returned by `prin1'." (sx-cache-get-file-name cache)) data) +(defun sx-cache--invalidate (cache &optional vars init-method) + "Set cache CACHE to nil. + +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) + (mapc #'makunbound vars) + (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")))) + (when save-auth + (setq caches (cl-remove-if (lambda (x) + (string= x "auth.el")) caches))) + (lwarn 'stack-mode :debug "Invalidating: %S" caches) + (mapc #'sx-cache--invalidate caches) + (sx-initialize 'force))) + (provide 'sx-cache) ;;; sx-cache.el ends here |