Skip to content

Commit

Permalink
allow no-caching for --get-namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jinnovation committed Apr 12, 2024
1 parent 97cdd1c commit 44ceb82
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions kele.el
Original file line number Diff line number Diff line change
Expand Up @@ -793,14 +793,19 @@ If value is nil, the namespaces need to be fetched directly.")
(setq kele--namespaces-cache
(assoc-delete-all (intern context) kele--namespaces-cache)))

(defun kele--get-namespaces (context)
;; TODO: test :cache nil
(cl-defun kele--get-namespaces (context &key (cache t))
"Get namespaces for CONTEXT.
If not cached, will fetch and cache the namespaces."
(if-let ((namespaces (alist-get (intern context) kele--namespaces-cache)))
namespaces
(apply #'kele--cache-namespaces context
(kele--fetch-resource-names nil "v1" "namespaces" :context context))))
If the namespaces are cached, return the cached value.
If CACHE is non-nil, cache the fetched namespaces."
(if-let ((cached-namespaces (alist-get (intern context) kele--namespaces-cache)))
cached-namespaces
(let ((namespaces (kele--fetch-resource-names nil "v1" "namespaces" :context context)))
(if cache
(apply #'kele--cache-namespaces context namespaces)
namespaces))))

(defun kele--get-cache-ttl-for-resource (resource)
"Get the cache TTL for RESOURCE."
Expand Down

0 comments on commit 44ceb82

Please sign in to comment.