SQLite key-value store wrapper
Find a file
Snider 072995f5d1
Some checks failed
security-scan.yml / chore(deps): bump dappco.re/go v0.10.3 → v0.10.4 (push) Failing after 0s
test.yml / chore(deps): bump dappco.re/go v0.10.3 → v0.10.4 (push) Failing after 0s
chore(deps): bump dappco.re/go v0.10.3 → v0.10.4
Advance external/go workspace submodule to v0.10.4 so dev (GOWORK on) and standalone (GOWORK=off) builds resolve the same core/go.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-06-13 10:08:17 +01:00
.core chore: add .core/ build and release configs 2026-03-06 18:52:37 +00:00
.forgejo/workflows ci: add Forgejo Actions test and security scan workflows 2026-02-23 03:28:08 +00:00
.github/workflows fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
docs fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
external chore(deps): bump dappco.re/go v0.10.3 → v0.10.4 2026-06-13 10:08:17 +01:00
go chore(deps): bump dappco.re/go v0.10.3 → v0.10.4 2026-06-13 10:08:17 +01:00
tests/cli/store chore(sonar): address 182 code smells (5.5 lane) 2026-04-30 14:12:09 +01:00
.editorconfig chore: add Go repo norms (badges, contributing, lint, taskfile, editorconfig) 2026-02-23 06:45:49 +00:00
.gitignore chore: add .core/ and .idea/ to .gitignore 2026-03-15 10:17:50 +00:00
.gitmodules refactor(go): restructure to /go/ subtree + audit COMPLIANT (Mantis #1250) 2026-04-30 22:32:31 +01:00
.golangci.yml fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
.woodpecker.yml ci: woodpecker pipeline (Go) — golangci-lint/eslint/phpstan + sonar.lthn.sh 2026-04-29 00:03:21 +01:00
AGENTS.md refactor(go): restructure to /go/ subtree + audit COMPLIANT (Mantis #1250) 2026-04-30 22:32:31 +01:00
CLAUDE.md Align module path docs 2026-04-15 11:22:20 +01:00
CODEX.md docs(ax): prefer declarative store configuration 2026-04-04 11:13:36 +00:00
CONTRIBUTING.md chore: add Go repo norms (badges, contributing, lint, taskfile, editorconfig) 2026-02-23 06:45:49 +00:00
DEPENDENCIES.md fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
go.work chore(repo): refresh submodules + go.work hygiene (Phase 2 cascade unblock) 2026-05-01 09:41:23 +01:00
LICENCE chore: add EUPL-1.2 LICENCE file (UK English canonical) 2026-05-01 08:35:06 +01:00
LICENCE.md fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
README.md fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
sonar-project.properties ci: woodpecker pipeline (Go) — golangci-lint/eslint/phpstan + sonar.lthn.sh 2026-04-28 23:33:36 +01:00

Go Reference Licence: 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 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/store Licence: EUPL-1.2 Language: Go 1.26

Quick Start

package main

import (
	"fmt"
	"time"

	"dappco.re/go/store"
)

func main() {
	// Configure a persistent store with "/tmp/go-store.db", or use ":memory:" for ephemeral data.
	storeInstance, err := store.NewConfigured(store.StoreConfig{
		DatabasePath: "/tmp/go-store.db",
		Journal: store.JournalConfiguration{
			EndpointURL:  "http://127.0.0.1:8086",
			Organisation: "core",
			BucketName:   "events",
		},
		PurgeInterval: 30 * time.Second,
		WorkspaceStateDirectory: "/tmp/core-state",
	})
	if err != nil {
		return
	}
	defer storeInstance.Close()

	if err := storeInstance.Set("config", "colour", "blue"); err != nil {
		return
	}
	if err := storeInstance.SetWithTTL("session", "token", "abc123", 24*time.Hour); err != nil {
		return
	}
	colourValue, err := storeInstance.Get("config", "colour")
	if err != nil {
		return
	}
	fmt.Println(colourValue)

	// Watch "config" mutations and print each event as it arrives.
	events := storeInstance.Watch("config")
	defer storeInstance.Unwatch("config", events)
	go func() {
		for event := range events {
			fmt.Println(event.Type, event.Group, event.Key, event.Value)
		}
	}()

	// Store tenant-42 preferences under the "tenant-42:" prefix.
	scopedStore, err := store.NewScopedConfigured(storeInstance, store.ScopedStoreConfig{
		Namespace: "tenant-42",
		Quota:     store.QuotaConfig{MaxKeys: 100, MaxGroups: 10},
	})
	if err != nil {
		return
	}
	if err := scopedStore.SetIn("preferences", "locale", "en-GB"); err != nil {
		return
	}
}

Documentation

  • Agent Conventions - Codex-facing repo rules and AX notes
  • AX RFC - naming, comment, and path conventions for agent consumers
  • 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
  • Dependency Exceptions — documented runtime dependency exceptions

Build & Test

go test ./...
go test -race ./...
go test -bench=. ./...
go build ./...

Licence

European Union Public Licence 1.2 — see LICENCE.md for details.