Coverage report: /home/ati/workspace/perec/query/cache.lisp
Kind | Covered | All | % |
expression | 29 | 34 | 85.3 |
branch | 2 | 2 | 100.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;; -*- mode: Lisp; Syntax: Common-Lisp; -*-
3
;;; Copyright (c) 2006 by the authors.
5
;;; See LICENCE for details.
9
(defvar *compiled-query-cache* (make-hash-table :test #'equal))
11
(defmethod execute-query (query &rest lexical-variable-values)
12
(let ((compiled-query (get-compiled-query query)))
13
(apply compiled-query lexical-variable-values)))
15
(defun clear-compiled-query-cache ()
16
(clrhash *compiled-query-cache*))
18
(defun get-compiled-query (query)
19
(let ((compiled-query (gethash (query-hash-key-for query) *compiled-query-cache*)))
20
(when (not compiled-query)
21
;; TODO: the query is copied here because the caller can change it
22
;; the change should remove the query from the cache instead
23
(setf query (copy-query query))
24
(setf compiled-query (compute-as* (:kind computed-class::standalone) (eval (compile-query query))))
25
(setf (gethash (query-hash-key-for query) *compiled-query-cache*) compiled-query))
26
(computed-state-value compiled-query)))
28
(defun remove-compiled-query (query)
29
(remhash (query-hash-key-for query) *compiled-query-cache*))