emacs-gitlab
emacs-gitlab copied to clipboard
Caching ?
Hi,
Do you plan to do some caching of the api results, and if so how would you implement it ?
very first iteration, using pcache: https://github.com/sigma/pcache (p for persistent)
(defvar gitlab-cache-expiry 3600 "Time expiry of cache, in seconds. Bypass it with an optional argument (C-u).") ;; bypass to do
(defun gitlab--perform-get-request (uri params)
"Doc string URI PARAMS. Cache requests."
(let* ((repo-name (concat "gitlab/" uri)) ;; so we can find our repositories easily
(repo (pcache-repository repo-name))
(data (pcache-get repo 'response)))
(if data
(pcache-get repo 'response)
(let* ((response (request (gitlab--get-rest-uri uri)
:type "GET"
:headers (gitlab--get-headers)
:sync t
:params params
;;:data params
:parser 'json-read)))
(pcache-put repo 'response response gitlab-cache-expiry)
response))))
it basically stores the request response into a cache object for a given number of seconds.
Not satisfactory yet 'cause
- there should be a way to bypass the cache (optional argument)
- we must cache not just the call to a given url but also take into account the parameters.
pcache doesn't have a list of created caches (apparently), and we may need one.