228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
;;
(define (db:open-inmem-db dbinit-proc)
(let* ((db (sqlite3:open-database ":memory:"))
(handler (sqlite3:make-busy-timeout 3600)))
(sqlite3:set-busy-handler! db handler)
(dbinit-proc db) ;; NOTE: inmem must always be initialized (db:initialize-db db)
db))
;; get and initalize dbstruct for a given run-id
;;
;; - uses db:initialize-db to create the schema
;;
;; Make the dbstruct, call for main db at least once
;; sync disk db to inmem
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
;;
(define (db:open-inmem-db dbinit-proc)
(let* ((db (sqlite3:open-database ":memory:"))
(handler (sqlite3:make-busy-timeout 3600)))
(sqlite3:set-busy-handler! db handler)
(dbinit-proc db) ;; NOTE: inmem must always be initialized (db:initialize-db db)
db))
;; for debugging we have a local mode. these routines support that mode
(define *dbcache* (make-hash-table))
(define (db:cache-get-dbstruct rid apath)
(let* ((dbname (db:run-id->dbname rid))
(dbfile (db:dbname->path apath dbname)))
(or (hash-table-ref/default *dbcache* dbfile #f)
(let* ((dbstruct (db:setup dbfile))) ;; (db:open-dbdat apath dbfile db:initialize-db)))
(hash-table-set! *dbcache* dbfile dbstruct)
dbstruct))))
(define (db:finalize-all-cache-dbstruct)
#f)
;; get and initalize dbstruct for a given run-id
;;
;; - uses db:initialize-db to create the schema
;;
;; Make the dbstruct, call for main db at least once
;; sync disk db to inmem
|