Commits

Hideo Hattori committed 810214b

use cache

Comments (0)

Files changed (1)

 # get supervisor contoroll processes
 (( $+functions[_get_supervisor_procs] )) ||
 _get_supervisor_procs() {
-    _supervisor_procs=(${${(f)"$(supervisorctl status >/dev/null 2>&1 | awk -F' ' '{print $1}')"}})
-    compadd -a _supervisor_procs
+    local cache_policy
+    zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
+    if [[ -z "$cache_policy" ]]; then
+        zstyle ":completion:${curcontext}:" cache-policy _supervisor_procs_caching_policy
+    fi
+
+    if ( [[ ${+_supervisor_procs} -eq 0 ]] || _cache_invalid supervisor_procs ) \
+        && ! _retrieve_cache supervisor_procs; then
+
+        _supervisor_procs=(${${(f)"$(supervisorctl status >/dev/null 2>&1 | awk -F' ' '{print $1}')"}})
+        _store_cache supervisor_procs _supervisor_procs
+    fi
+
+    local expl
+    _wanted supervisor_procs expl 'supervisor processes' compadd -a _supervisor_procs
+}
+
+_supervisor_procs_caching_policy() {
+    local -a oldp
+    oldp=( "$1"(Nmw+1) )
+    (( $#oldp ))
 }
 
 (( $+functions[_supervisorctl_add] )) ||