db-cacheing
This commit is contained in:
parent
5c1495a0ce
commit
51be2041db
|
@ -1,18 +1,43 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require (planet ryanc/db)
|
(require (planet ryanc/db)
|
||||||
"../version.rkt")
|
(prefix-in whalesong: "../version.rkt")
|
||||||
|
racket/file
|
||||||
|
racket/path)
|
||||||
|
|
||||||
|
(define cache-directory-path
|
||||||
|
(build-path (find-system-path 'pref-dir)
|
||||||
|
"whalesong"))
|
||||||
|
|
||||||
|
|
||||||
(when (not (file-exists? "whalesong-cache.sqlite3"))
|
|
||||||
|
;; create-cache-directory!: -> void
|
||||||
|
(define (create-cache-directory!)
|
||||||
|
(unless (directory-exists? cache-directory-path)
|
||||||
|
(make-directory* cache-directory-path)))
|
||||||
|
|
||||||
|
(create-cache-directory!)
|
||||||
|
|
||||||
|
(define whalesong-cache.sqlite3
|
||||||
|
(build-path cache-directory-path
|
||||||
|
(format "whalesong-cache-~a.sqlite"
|
||||||
|
whalesong:version)))
|
||||||
|
|
||||||
|
|
||||||
|
(when (not (file-exists? whalesong-cache.sqlite3))
|
||||||
(define conn
|
(define conn
|
||||||
(sqlite3-connect #:database "whalesong-cache.sqlite3"
|
(sqlite3-connect #:database whalesong-cache.sqlite3
|
||||||
#:mode 'create))
|
#:mode 'create))
|
||||||
|
(query-exec conn
|
||||||
|
(string-append
|
||||||
|
"create table cache(path string not null primary key, "
|
||||||
|
" md5sum string not null, "
|
||||||
|
"data blob not null);"))
|
||||||
(disconnect conn))
|
(disconnect conn))
|
||||||
|
|
||||||
|
|
||||||
(define conn
|
(define conn
|
||||||
(sqlite3-connect #:database "whalesong-cache.sqlite3"))
|
(sqlite3-connect #:database whalesong-cache.sqlite3))
|
||||||
|
|
||||||
|
|
||||||
(define (cached? path)
|
(define (cached? path)
|
||||||
|
|
|
@ -32,10 +32,3 @@
|
||||||
(parse-bytecode x)]
|
(parse-bytecode x)]
|
||||||
[else
|
[else
|
||||||
(parse-bytecode x)]))
|
(parse-bytecode x)]))
|
||||||
|
|
||||||
|
|
||||||
(define cache-dir (build-path (find-system-path 'pref-dir)
|
|
||||||
"whalesong"
|
|
||||||
whalesong:version))
|
|
||||||
(unless (directory-exists? cache-dir)
|
|
||||||
(make-directory* cache-dir))
|
|
|
@ -6,4 +6,4 @@
|
||||||
|
|
||||||
(provide version)
|
(provide version)
|
||||||
(: version String)
|
(: version String)
|
||||||
(define version "1.8")
|
(define version "1.10")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user