mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-07 11:10:18 -08:00
Added with-connection-cache for minimizing wire traffic on large setups of pages.
This commit is contained in:
parent
ad6a4ad585
commit
28e9b45059
4 changed files with 204 additions and 144 deletions
|
|
@ -717,6 +717,25 @@ an application share per connection the same queue of serialized events.</p></li
|
|||
<p>Returns true if connection is valid on this <code>CLOG-OBJ</code>.</p></li>
|
||||
</ul>
|
||||
|
||||
<p><a id="x-28CLOG-3AWITH-CONNECTION-CACHE-20MGL-PAX-3AMACRO-29"></a>
|
||||
<a id="CLOG:WITH-CONNECTION-CACHE%20MGL-PAX:MACRO"></a></p>
|
||||
|
||||
<ul>
|
||||
<li><p><span class=reference-bullet><span class=reference><span class="locative-type">[macro]</span> <span class="reference-object"><a href="#CLOG:WITH-CONNECTION-CACHE%20MGL-PAX:MACRO" >WITH-CONNECTION-CACHE</a></span></span> <span class="locative-args">(CLOG-OBJ) &BODY BODY</span></span></p>
|
||||
|
||||
<p>Caches writes to the connection-id of <code>CLOG-OBJ</code> until
|
||||
flushed with <a href="#CLOG:FLUSH-CONNECTION-CACHE%20FUNCTION" title="CLOG:FLUSH-CONNECTION-CACHE FUNCTION"><code>FLUSH-CONNECTION-CACHE</code></a> or a query is made.</p></li>
|
||||
</ul>
|
||||
|
||||
<p><a id="x-28CLOG-3AFLUSH-CONNECTION-CACHE-20FUNCTION-29"></a>
|
||||
<a id="CLOG:FLUSH-CONNECTION-CACHE%20FUNCTION"></a></p>
|
||||
|
||||
<ul>
|
||||
<li><p><span class=reference-bullet><span class=reference><span class="locative-type">[function]</span> <span class="reference-object"><a href="#CLOG:FLUSH-CONNECTION-CACHE%20FUNCTION" >FLUSH-CONNECTION-CACHE</a></span></span> <span class="locative-args">CLOG-OBJ</span></span></p>
|
||||
|
||||
<p>Flush connection cache if on.</p></li>
|
||||
</ul>
|
||||
|
||||
<p>CLOG-Obj - Internals for Extensions and Plugins</p>
|
||||
|
||||
<p><a id="x-28CLOG-3AHTML-ID-20GENERIC-FUNCTION-29"></a>
|
||||
|
|
@ -8151,10 +8170,11 @@ result or <code>DEFAULT-ANSWER</code> on time out.</p></li>
|
|||
<a id="CLOG:CLOG-REPL%20FUNCTION"></a></p>
|
||||
|
||||
<ul>
|
||||
<li><p><span class=reference-bullet><span class=reference><span class="locative-type">[function]</span> <span class="reference-object"><a href="#CLOG:CLOG-REPL%20FUNCTION" >CLOG-REPL</a></span></span></span></p>
|
||||
<li><p><span class=reference-bullet><span class=reference><span class="locative-type">[function]</span> <span class="reference-object"><a href="#CLOG:CLOG-REPL%20FUNCTION" >CLOG-REPL</a></span></span> <span class="locative-args">&KEY (CLOG-GUI-INITIALIZE <code>T</code>) (CLOG-WEB-INITIALIZE <code>T</code>)</span></span></p>
|
||||
|
||||
<p>Set a path /repl that opens a blank page and sets the global
|
||||
clog-user:<em>body</em> to last window openned to /repl.</p></li>
|
||||
clog-user:<em>body</em> to last window openned to /repl. Debug mode is
|
||||
set (logging to browser console), </p></li>
|
||||
</ul>
|
||||
|
||||
<p><a id="x-28CLOG-3ASAVE-BODY-TO-FILE-20FUNCTION-29"></a>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,16 @@
|
|||
;;; methods to retrieve connection-data (data that is associated with the
|
||||
;;; current page regardless of object or thread of execution is lisp).
|
||||
|
||||
(push :clog *features*)
|
||||
(pushnew :clog *features*)
|
||||
|
||||
(defvar *connection-cache* nil
|
||||
"Dynamic variable containing optional cache. Every thread has its
|
||||
own context and therefore its own copy of this variable when
|
||||
dynamically bound. As a result no thread protection is needed to
|
||||
access. To use dynamically bind the *connection-cache* and set it
|
||||
to (list :cache) turn on caching. By default this is off its main use
|
||||
is in initial setup complex pages. (private)
|
||||
See macro with-connection-cache.")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Implementation - clog-obj
|
||||
|
|
@ -84,9 +93,34 @@ during attachment. (Private)"))
|
|||
dicarded, return CLOG-OBJ. (Internal)"))
|
||||
|
||||
(defmethod js-execute ((obj clog-obj) script)
|
||||
(clog-connection:execute (connection-id obj) script)
|
||||
(if *connection-cache*
|
||||
(push script *connection-cache*)
|
||||
(clog-connection:execute (connection-id obj) script))
|
||||
obj)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; with-connection-cache ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defmacro with-connection-cache ((clog-obj) &body body)
|
||||
"Caches writes to the connection-id of CLOG-OBJ until
|
||||
flushed with FLUSH-CONNECTION-CACHE or a query is made."
|
||||
`(let ((*connection-cache* (list :cache)))
|
||||
,@body
|
||||
(clog:flush-connection-cache ,clog-obj)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; flush-connection-cache ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun flush-connection-cache (clog-obj)
|
||||
"Flush connection cache if on."
|
||||
(when *connection-cache*
|
||||
(dolist (script (reverse *connection-cache*))
|
||||
(unless (eq script :cache)
|
||||
(clog-connection:execute (connection-id clog-obj) script)))
|
||||
(setf *connection-cache* (list :cache))))
|
||||
|
||||
;;;;;;;;;;;;;;
|
||||
;; js-query ;;
|
||||
;;;;;;;;;;;;;;
|
||||
|
|
@ -95,6 +129,7 @@ dicarded, return CLOG-OBJ. (Internal)"))
|
|||
(:documentation "Execure SCRIPT on browser and return result. (Internal)"))
|
||||
|
||||
(defmethod js-query ((obj clog-obj) script &key (default-answer nil))
|
||||
(flush-connection-cache obj)
|
||||
(clog-connection:query (connection-id obj) script :default-answer default-answer))
|
||||
|
||||
;;;;;;;;;;;;;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ embedded in a native template application.)"
|
|||
(with-sync-event macro)
|
||||
(remove-connection-data-item generic-function)
|
||||
(validp generic-function)
|
||||
(with-connection-cache macro)
|
||||
(flush-connection-cache function)
|
||||
|
||||
"CLOG-Obj - Internals for Extensions and Plugins"
|
||||
(html-id generic-function)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
(defun on-new-window (body)
|
||||
(setf (title (html-document body)) "Tutorial 9")
|
||||
;; When doing extensive setup of a page using connection cache
|
||||
;; reduces rountrip traffic and speeds setup considerably.
|
||||
(with-connection-cache (body)
|
||||
(let* (last-tab
|
||||
;; Note: Since the there is no need to use the tmp objects
|
||||
;; we reuse the same symbol name (tmp) even though the
|
||||
|
|
@ -153,7 +156,7 @@
|
|||
(select-tab p2)))
|
||||
(set-on-click t3 (lambda (obj)
|
||||
(setf last-tab obj)
|
||||
(select-tab p3))))))
|
||||
(select-tab p3)))))))
|
||||
|
||||
(defun start-tutorial ()
|
||||
"Start turtorial."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue