Improve caching

This commit is contained in:
David Botton 2024-03-12 16:37:20 -04:00
parent 1c9fa342ad
commit 370b28fc74
2 changed files with 13 additions and 6 deletions

View file

@ -84,6 +84,16 @@ during attachment. (Private)"))
"'body'"
(format nil "clog['~A']" (html-id obj))))
;;;;;;;;;;;;;;;;;;;
;; cached-excute ;;
;;;;;;;;;;;;;;;;;;;
(defun cached-execute (connection-id script)
"Excute SCRIPT on browser, if connection cache enabled use. (Private)"
(if *connection-cache*
(push script *connection-cache*)
(clog-connection:execute connection-id script)))
;;;;;;;;;;;;;;;;
;; js-execute ;;
;;;;;;;;;;;;;;;;
@ -93,9 +103,7 @@ during attachment. (Private)"))
discarded, return CLOG-OBJ. (Internal)"))
(defmethod js-execute ((obj clog-obj) script)
(if *connection-cache*
(push script *connection-cache*)
(clog-connection:execute (connection-id obj) script))
(cached-execute (connection-id obj) script)
obj)
;;;;;;;;;;;;;;

View file

@ -49,8 +49,7 @@ clog array but is not in the DOM. If HTML-ID is nil one is generated.
(let ((web-id (if html-id
html-id
(format nil "CLOG~A" (generate-id)))))
(clog-connection:execute
connection-id
(cached-execute connection-id
(format nil
"clog['~A']=$(\"~A\").get(0); $(clog['~A']).first().prop('id','~A')"
web-id html web-id web-id))
@ -63,7 +62,7 @@ clog array but is not in the DOM. If HTML-ID is nil one is generated.
(defun attach (connection-id html-id)
"Create a new clog-obj and attach an existing element with HTML-ID on
CONNECTION-ID to it and then return it. The HTML-ID must be unique. (private)"
(clog-connection:execute connection-id
(cached-execute connection-id
(format nil "clog['~A']=$('#~A').get(0)" html-id html-id))
(make-clog-element connection-id html-id))