From d6a7449d4a3a6d6912c8793c92220d3e0045c05e Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Fri, 17 Apr 2026 22:13:56 +0200 Subject: [PATCH] - --- scrbl/.gitignore | 5 +++++ scrbl/keystore.html | 13 ------------- scrbl/keystore.scrbl | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) create mode 100644 scrbl/.gitignore delete mode 100644 scrbl/keystore.html diff --git a/scrbl/.gitignore b/scrbl/.gitignore new file mode 100644 index 0000000..966169e --- /dev/null +++ b/scrbl/.gitignore @@ -0,0 +1,5 @@ +*.html +*.js +*.css +*~ +*.bak diff --git a/scrbl/keystore.html b/scrbl/keystore.html deleted file mode 100644 index 0974f6d..0000000 --- a/scrbl/keystore.html +++ /dev/null @@ -1,13 +0,0 @@ - -Keystore
9.1

KeystoreπŸ”—

 (require keystore)

A small persistent key–value store backed by SQLite. Keys and values -may be arbitrary Racket values and are stored using transparent -serialization.

1 OverviewπŸ”—

The keystore provides persistent storage with automatic -serialization and deserialization. Keys are additionally stored in a -stringified lowercase form, which allows glob-style queries.

2 StructureπŸ”—

struct

(struct keystore (file path dbh))

  file : any/c
  path : path?
  dbh : any/c
Represents an open keystore. The file field contains the -original argument, path is the resolved database path, and -dbh is the SQLite connection.

3 OpeningπŸ”—

procedure

(ks-open file)  keystore?

  file : (or/c path? string? symbol?)
Opens or creates a keystore. When file is a symbol, a cache -location is used; otherwise it is interpreted as a filesystem path. -The database schema is created automatically if it does not yet exist.

4 Basic OperationsπŸ”—

procedure

(ks-set! ks key value)  boolean?

  ks : keystore?
  key : any/c
  value : any/c
Stores value under key, replacing any existing value. -The function always returns #t.

procedure

(ks-get ks key default ...)  any/c

  ks : keystore?
  key : any/c
  default : any/c
Retrieves the value associated with key. If the key is not -present, the provided default value is returned when given; otherwise -the symbol 'ks-nil is returned.

procedure

(ks-exists? ks key)  boolean?

  ks : keystore?
  key : any/c
Returns #t if the key exists, and #f otherwise.

procedure

(ks-drop! ks key)  boolean?

  ks : keystore?
  key : any/c
Removes the key from the store. The function always returns #t.

5 EnumerationπŸ”—

procedure

(ks-keys ks)  (listof any/c)

  ks : keystore?
Returns all keys in the store.

procedure

(ks-key-values ks)  (listof (cons/c any/c any/c))

  ks : keystore?
Returns all key–value pairs as cons cells.

6 Glob QueriesπŸ”—

Glob queries operate on a lowercase string representation of keys.

procedure

(ks-keys-glob ks pattern)  (listof any/c)

  ks : keystore?
  pattern : string?
Returns all keys whose string form matches pattern.

procedure

(ks-key-values-glob ks pattern)  (listof (cons/c any/c any/c))

  ks : keystore?
  pattern : string?
Returns key–value pairs whose keys match pattern.

7 Raw AccessπŸ”—

procedure

(ks-keys-raw ks)  list?

  ks : keystore?
Returns raw key rows in the form:

(list key-string str-key)

procedure

(ks-key-values-raw ks)  list?

  ks : keystore?
Returns raw key–value rows in the form:

(list key-string str-key value-string)

8 ExamplesπŸ”—

8.1 Basic UsageπŸ”—

(define ks (ks-open 'demo))
 
(ks-set! ks 'a 42)
(ks-set! ks "b" '(1 2 3))
 
(ks-get ks 'a)
(ks-get ks 'missing)
(ks-get ks 'missing 0)

8.2 EnumerationπŸ”—

(ks-keys ks)
 
 
(ks-key-values ks)

8.3 Glob Query ExampleπŸ”—

(ks-keys-glob ks "*b*")

 
\ No newline at end of file diff --git a/scrbl/keystore.scrbl b/scrbl/keystore.scrbl index 738bf0e..4cd9208 100644 --- a/scrbl/keystore.scrbl +++ b/scrbl/keystore.scrbl @@ -122,7 +122,7 @@ Returns raw key–value rows in the form: (ks-get ks 'missing 0) ; => 0 ] -@subsection{Enumeration} +@subsection{Enumeration Example} @racketblock[ (ks-keys ks)