aboutsummaryrefslogtreecommitdiff
path: root/guix-qa-frontpage
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-04-20 10:09:55 +0100
committerChristopher Baines <mail@cbaines.net>2023-04-20 10:09:55 +0100
commit25eff460e838b22ddf8b51c96036e0dc141e8b98 (patch)
treef4ecc330bfc0b0f36f982ed13cf174ab8f7efc98 /guix-qa-frontpage
parent5ec130d142a8a40537d065ce2a470a9388ff3c36 (diff)
downloadqa-frontpage-25eff460e838b22ddf8b51c96036e0dc141e8b98.tar
qa-frontpage-25eff460e838b22ddf8b51c96036e0dc141e8b98.tar.gz
Move the cache entry version in to the key
This simplifies the database, and makes it easier to put an index on the key column.
Diffstat (limited to 'guix-qa-frontpage')
-rw-r--r--guix-qa-frontpage/database.scm16
1 files changed, 8 insertions, 8 deletions
diff --git a/guix-qa-frontpage/database.scm b/guix-qa-frontpage/database.scm
index d8d7d73..d924f31 100644
--- a/guix-qa-frontpage/database.scm
+++ b/guix-qa-frontpage/database.scm
@@ -69,11 +69,11 @@
"
CREATE TABLE cache (
key TEXT NOT NULL,
- version INTEGER NOT NULL,
timestamp INTEGER NOT NULL,
data TEXT NOT NULL
);
-")
+
+CREATE UNIQUE INDEX IF NOT EXISTS cache_idx ON cache (key);")
(sqlite-exec db schema))
@@ -370,6 +370,8 @@ DELETE FROM cache WHERE key = :key"
(call-with-output-string
(lambda (port)
(write key port)
+ (display "|" port)
+ (write version port)
(display ": " port)
(write args port))))
@@ -384,13 +386,12 @@ DELETE FROM cache WHERE key = :key"
(sqlite-prepare
db
"
-SELECT data, timestamp FROM cache WHERE key = :key AND version = :version"
+SELECT data, timestamp FROM cache WHERE key = :key"
#:cache? #t)))
(sqlite-bind-arguments
statement
- #:key string-key
- #:version version)
+ #:key string-key)
(let ((result (sqlite-step statement)))
(sqlite-reset statement)
@@ -435,8 +436,8 @@ DELETE FROM cache WHERE key = :key"
(sqlite-prepare
db
"
-INSERT INTO cache (key, version, timestamp, data)
-VALUES (:key, :version, :timestamp, :data)"
+INSERT INTO cache (key, timestamp, data)
+VALUES (:key, :timestamp, :data)"
#:cache? #t)))
(sqlite-bind-arguments
@@ -448,7 +449,6 @@ VALUES (:key, :version, :timestamp, :data)"
(sqlite-bind-arguments
insert-statement
#:key string-key
- #:version version
#:timestamp (time-second (current-time))
#:data (call-with-output-string
(lambda (port)