Keystore Class
| (require keystore/class) |
An object-oriented wrapper around keystore. It provides +a small class interface to the persistent key–value store.
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.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.Removes key from the store and returns the object itself.Returns #t if key exists, and #f otherwise.Returns keys matching pattern.Returns key–value pairs matching pattern.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*")