Lockable memory storage for Go https://pkg.go.dev/github.com/annybs/go-registry
|
10 ヶ月 前 | |
---|---|---|
.github | 10 ヶ月 前 | |
.gitignore | 10 ヶ月 前 | |
LICENSE.md | 11 ヶ月 前 | |
README.md | 10 ヶ月 前 | |
go.mod | 10 ヶ月 前 | |
registry.go | 11 ヶ月 前 | |
registry_test.go | 1 年間 前 |
This package provides a simple registry implementation which allows storing arbitrary values in a memory map.
You can also lock specific keys to prevent them being written, even if no value has yet been set. Locked keys cannot be unlocked.
package main
import (
"fmt"
"github.com/annybs/go/registry"
)
func main() {
r := registry.New()
r.Set("some key", "some text")
fmt.Println(r.Get("some key"))
r.Lock("some key")
if err := r.Set("some key", "different text"); err != nil {
fmt.Println(err)
}
}
See LICENSE.md