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