💿 In-memory key value store that saves your data to disk using JSON.
11 Commits
.editorconfig | ||
.gitignore | ||
Collection_test.go | ||
Collection.go | ||
go.mod | ||
go.sum | ||
LICENSE | ||
README.md |
ocean
In-memory key value store that saves your data to plain old JSON files.
If you like, you can operate on your entire data with classic UNIX tools.
Let's say we use this struct to save our user data:
type User struct {
Name string
}
Then we can create a typesafe collection using Go generics:
// Data saved to ~/.ocean/User/
users := ocean.New[User]("User")
// Store key and value in memory and write ~/.ocean/User/1.json
users.Set("1", &User{Name: "User 1"})
In a real project you would usually prefix your collections with a project or company name:
// Data saved to ~/.ocean/google/User/
users := ocean.New[User]("google", "User")
You can add as many hierarchies as you need but I recommend using a simple /namespace/collection/
structure.