Keystore Class
keystore%
new
handle
set!
get
drop!
exists?
glob
glob-kv
keys-glob
keys
key-values
1 Examples
1.1 Basic Usage
1.2 Nested Calls
1.3 Glob Queries
9.1

Keystore Class🔗ℹ

 (require keystore/class) package: keystore

An object-oriented wrapper around keystore. It provides a small class interface to the persistent key-value store.

class

keystore% : class?

  superclass: object%

A keystore class backed by SQLite.

constructor

(new keystore% [file file])  (is-a?/c keystore%)

  file : (or/c path? string? symbol?)
Opens or creates a keystore using file. The meaning of file is the same as for ks-open.

method

(send a-keystore handle)  keystore?

Returns the underlying keystore handle.

method

(send a-keystore set! key value)  (is-a?/c keystore%)

  key : any/c
  value : any/c
Stores value under key. Returns the object itself, so method calls may be nested.

method

(send a-keystore get key default ...)  any/c

  key : any/c
  default : any/c
Retrieves the value associated with key. If no value is found, the optional default is returned; otherwise 'ks-nil is returned.

method

(send a-keystore drop! key)  (is-a?/c keystore%)

  key : any/c
Removes key from the store and returns the object itself.

method

(send a-keystore exists? key)  boolean?

  key : any/c
Returns #t if key exists, and #f otherwise.

method

(send a-keystore glob pattern)  (listof any/c)

  pattern : string?
Returns keys matching pattern.

method

(send a-keystore glob-kv pattern)

  (listof (cons/c any/c any/c))
  pattern : string?
Returns key=value pairs matching pattern.

method

(send a-keystore keys-glob pattern)  (listof any/c)

  pattern : string?
Alias for glob.

method

(send a-keystore keys)  (listof any/c)

Returns all keys.

method

(send a-keystore key-values)  (listof (cons/c any/c any/c))

Returns all key-value pairs.

1 Examples🔗ℹ

1.1 Basic Usage🔗ℹ

(define ks (new keystore% [file 'demo]))
 
(send ks set! 'a 42)
(send ks set! "b" '(1 2 3))
 
(send ks get 'a)
(send ks get 'missing)
(send ks get 'missing 0)

1.2 Nested Calls🔗ℹ

(define ks (new keystore% [file 'demo]))
 
(send (send (send ks set! 'a 1)
            set! 'b 2)
      drop! 'a)

1.3 Glob Queries🔗ℹ

(send ks glob "*b*")
(send ks glob-kv "*b*")