go-store/doc.go
Virgil fdadc24579
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m40s
docs(store): align remaining AX examples
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 17:32:09 +00:00

51 lines
1.4 KiB
Go

// Package store provides SQLite-backed storage for grouped entries, TTL expiry,
// namespace isolation, and reactive change notifications.
//
// Usage example:
//
// func main() {
// storeInstance, err := store.New(":memory:")
// if err != nil {
// return
// }
// defer storeInstance.Close()
//
// if err := storeInstance.Set("config", "theme", "dark"); err != nil {
// return
// }
// themeValue, err := storeInstance.Get("config", "theme")
// if err != nil {
// return
// }
// fmt.Println(themeValue)
//
// scopedStore, err := store.NewScoped(storeInstance, "tenant-a")
// if err != nil {
// return
// }
// if err := scopedStore.Set("config", "theme", "dark"); err != nil {
// return
// }
//
// quotaScopedStore, err := store.NewScopedWithQuota(storeInstance, "tenant-b", store.QuotaConfig{MaxKeys: 100, MaxGroups: 10})
// if err != nil {
// return
// }
// if err := quotaScopedStore.Set("prefs", "locale", "en-GB"); err != nil {
// return
// }
//
// 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)
// }
// }()
//
// unregister := storeInstance.OnChange(func(event store.Event) {
// fmt.Println("changed", event.Group, event.Key, event.Value)
// })
// defer unregister()
// }
package store