db-cacheing

This commit is contained in:
Danny Yoo 2011-09-23 11:39:57 -04:00
parent 5c1495a0ce
commit 51be2041db
3 changed files with 32 additions and 14 deletions

View File

@ -1,18 +1,43 @@
#lang racket/base
(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"))
(define conn
(sqlite3-connect #:database "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
(sqlite3-connect #:database whalesong-cache.sqlite3
#:mode 'create))
(disconnect conn))
(query-exec conn
(string-append
"create table cache(path string not null primary key, "
" md5sum string not null, "
"data blob not null);"))
(disconnect conn))
(define conn
(sqlite3-connect #:database "whalesong-cache.sqlite3"))
(sqlite3-connect #:database whalesong-cache.sqlite3))
(define (cached? path)

View File

@ -32,10 +32,3 @@
(parse-bytecode x)]
[else
(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))

View File

@ -6,4 +6,4 @@
(provide version)
(: version String)
(define version "1.8")
(define version "1.10")