@@ -818,10 +818,14 @@ (db:test-set-state! res "NOT_STARTED") (db:test-set-status! res "n/a"))))) (define *last-test-cache-delete* (current-seconds)) +(define (db:clean-all-caches) + (set! *test-info* (make-hash-table)) + (set! *test-id-cache* (make-hash-table))) + ;; Get test data using test_id (define (db:get-test-info-cached-by-id db test-id) ;; is all this crap really worth it? I somehow doubt it. (let* ((last-delete-str (db:get-var db "DELETED_TESTS")) (last-delete (if (string? last-delete-str)(string->number last-delete-str) #f))) @@ -834,11 +838,12 @@ (if (not test-id) (begin (debug:print 4 "INFO: db:get-test-info-by-id called with test-id=" test-id) #f) (let* ((res (hash-table-ref/default *test-info* test-id #f))) - (if res + (if (and res + (member (db:test-get-state res) '("RUNNING" "COMPLETED"))) (db:patch-tdb-data-into-test-info db test-id res) ;; if no cached value then full read and write to cache (begin (sqlite3:for-each-row (lambda (id run-id testname state status event-time host cpuload diskfree uname rundir item-path run_duration final_logf comment) @@ -864,11 +869,11 @@ db "SELECT id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment FROM tests WHERE id=?;" test-id) res))) -(define db:get-test-info-by-id db:get-test-info-cached-by-id) +(define db:get-test-info-by-id db:get-test-info-not-cached-by-id) (define (db:get-test-info db run-id testname item-path) (db:get-test-info-by-id db (db:get-test-id db run-id testname item-path))) (define (db:test-set-comment db test-id comment)