go-store/README.md
Virgil 36a8d89677
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m40s
refactor(store): tighten AX naming
Replace the remaining shorthand variable names in the implementation, examples, and supporting docs with explicit names.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 15:02:28 +00:00

2.1 KiB

Go Reference License: EUPL-1.2 Go Version

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 ensure pragma consistency. Supports scoped stores for multi-tenant use, Watch/Unwatch subscriptions, and OnChange callbacks — the designed integration point for go-ws real-time streaming.

Module: dappco.re/go/core/store Licence: EUPL-1.2 Language: Go 1.25

Quick Start

package main

import (
	"fmt"
	"time"

	"dappco.re/go/core/store"
)

func main() {
	storeInstance, err := store.New("/path/to/store.db") // or store.New(":memory:")
	if err != nil {
		panic(err)
	}
	defer storeInstance.Close()

	storeInstance.Set("config", "theme", "dark")
	storeInstance.SetWithTTL("session", "token", "abc123", 24*time.Hour)
	value, err := storeInstance.Get("config", "theme")
	fmt.Println(value, err)

	// Watch for mutations
	watcher := storeInstance.Watch("config", "*")
	defer storeInstance.Unwatch(watcher)
	go func() {
		for event := range watcher.Events {
			fmt.Println(event.Type, event.Key)
		}
	}()

	// Scoped store for tenant isolation
	scopedStore, _ := store.NewScoped(storeInstance, "tenant-42")
	scopedStore.Set("prefs", "locale", "en-GB")
}

Documentation

  • 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.