SQLite key-value store wrapper
|
|
||
|---|---|---|
| .core | ||
| .forgejo/workflows | ||
| .github/workflows | ||
| docs | ||
| .editorconfig | ||
| .gitignore | ||
| .golangci.yml | ||
| bench_test.go | ||
| CLAUDE.md | ||
| CODEX.md | ||
| CONTRIBUTING.md | ||
| conventions_test.go | ||
| coverage_test.go | ||
| doc.go | ||
| events.go | ||
| events_test.go | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
| scope.go | ||
| scope_test.go | ||
| store.go | ||
| store_test.go | ||
| test_helpers_test.go | ||
go-store
Group-namespaced SQLite key-value store with TTL expiry, namespace isolation, quota enforcement, and a reactive event system. Backed by a pure-Go SQLite driver (no CGO), uses WAL mode for concurrent reads, and enforces a single connection to keep pragma settings consistent. Supports scoped stores for multi-tenant use, Watch/Unwatch subscriptions, and OnChange callbacks for downstream event consumers.
Module: dappco.re/go/core/store
Licence: EUPL-1.2
Language: Go 1.26
Quick Start
package main
import (
"fmt"
"time"
"dappco.re/go/core/store"
)
func main() {
// Store the database on disk with "/tmp/go-store.db", or use ":memory:" for ephemeral data.
storeInstance, err := store.New("/tmp/go-store.db")
if err != nil {
return
}
defer storeInstance.Close()
if err := storeInstance.Set("config", "theme", "dark"); err != nil {
return
}
if err := storeInstance.SetWithTTL("session", "token", "abc123", 24*time.Hour); err != nil {
return
}
themeValue, err := storeInstance.Get("config", "theme")
if err != nil {
return
}
fmt.Println(themeValue)
// Watch config mutations on a buffered channel.
watcher := storeInstance.Watch("config", "*")
defer storeInstance.Unwatch(watcher)
go func() {
for event := range watcher.Events {
fmt.Println(event.Type, event.Group, event.Key, event.Value)
}
}()
// Prefix tenant-42 preferences with "tenant-42:".
scopedStore, err := store.NewScoped(storeInstance, "tenant-42")
if err != nil {
return
}
if err := scopedStore.Set("prefs", "locale", "en-GB"); err != nil {
return
}
}
Documentation
- Agent Conventions - Codex-facing repo rules and AX notes
- Architecture — storage layer, group/key model, TTL expiry, event system, namespace isolation
- Development Guide — prerequisites, test patterns, benchmarks, adding methods
- Project History — completed phases, known limitations, future considerations
Build & Test
go test ./...
go test -race ./...
go test -bench=. ./...
go build ./...
Licence
European Union Public Licence 1.2 — see LICENCE for details.