-
Notifications
You must be signed in to change notification settings - Fork 95
/
main.go
34 lines (28 loc) · 697 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// A basic example of using Redka
// with github.com/mattn/go-sqlite3 driver.
package main
import (
"log"
"log/slog"
_ "github.com/mattn/go-sqlite3"
"github.com/nalgeon/redka"
)
func main() {
// Open a database.
db, err := redka.Open("data.db", nil)
if err != nil {
log.Fatal(err)
}
defer db.Close()
// Set some string keys.
err = db.Str().Set("name", "alice")
slog.Info("set", "err", err)
err = db.Str().Set("age", 25)
slog.Info("set", "err", err)
// Check if the keys exist.
count, err := db.Key().Count("name", "age", "city")
slog.Info("count", "count", count, "err", err)
// Get a key.
name, err := db.Str().Get("name")
slog.Info("get", "name", name, "err", err)
}