Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -2315,10 +2315,11 @@ ;; ;; NB// Ultimately this will be deprecated in deference to mt:test-set-state-status-by-id ;; ;; NOTE: run-id is not used ;; ;; (define (db:test-set-state-status dbstruct run-id test-id newstate newstatus newcomment) + (hash-table-delete! *db:get-test-info-by-id-cache* (cons run-id test-id)) (db:with-db dbstruct run-id #t (lambda (dbdat db) (db:test-set-state-status-db db run-id test-id newstate newstatus newcomment)))) @@ -2610,27 +2611,34 @@ ;; (conc "SELECT " db:test-record-qry-selector " FROM tests WHERE id=? AND run_id=?;")) (conc "SELECT " db:test-record-qry-selector " FROM tests WHERE id=? AND run_id=?;") test-id run-id) res)))) +(define *db:get-test-info-by-id-cache* (make-hash-table)) + ;; Get test state, status using test_id ;; (define (db:get-test-state-status-by-id dbstruct run-id test-id) - (db:with-db - dbstruct - run-id - #f - (lambda (dbdat db) - (let ((res (cons #f #f))) -;; (stmth (db:get-cache-stmth dbdat db "SELECT state,status FROM tests WHERE id=?;"))) - (sqlite3:for-each-row ;; attemptnum added to hold pid of top process (not Megatest) controlling a test - (lambda (state status) - (cons state status)) - db - "SELECT state,status FROM tests WHERE id=? AND run_id=?;" ;; stmth try not compiling this one - yes, this fixed the bind issue - test-id run-id) - res)))) + (let* ((hash-key (cons run-id test-id)) + (cache-result (hash-table-ref/default *db:get-test-info-by-id-cache* hash-key #f))) + (if cache-result + (cdr cache-result) + (db:with-db + dbstruct + run-id + #f + (lambda (dbdat db) + (let ((res (cons #f #f))) + ;; (stmth (db:get-cache-stmth dbdat db "SELECT state,status FROM tests WHERE id=?;"))) + (sqlite3:for-each-row ;; attemptnum added to hold pid of top process (not Megatest) controlling a test + (lambda (state status) + (cons state status)) + db + "SELECT state,status FROM tests WHERE id=? AND run_id=?;" ;; stmth try not compiling this one - yes, this fixed the bind issue + test-id run-id) + (hash-table-set! *db:get-test-info-by-id-cache* hash-key (cons (current-seconds) res)) + res)))))) ;; Use db:test-get* to access ;; Get test data using test_ids. NB// Only works within a single run!! ;; (define (db:get-test-info-by-ids dbstruct run-id test-ids)