41 lines
850 B
Markdown
41 lines
850 B
Markdown
# 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.
|
|
|
|
Suitable for small to medium data volume.
|
|
|
|
## Installation
|
|
|
|
```shell
|
|
go get git.akyoto.dev/go/ocean
|
|
```
|
|
|
|
## Example
|
|
|
|
```go
|
|
// User data
|
|
type User struct {
|
|
Name string
|
|
}
|
|
|
|
// Load existing data from ~/.ocean/User/
|
|
users := ocean.New[User]()
|
|
|
|
// Store in memory and also store in ~/.ocean/User/1.json
|
|
users.Set("1", &User{Name: "User 1"})
|
|
|
|
// Read from memory
|
|
user, err := users.Get("1")
|
|
```
|
|
|
|
In a real project you would usually prefix your collections with a project or company name:
|
|
|
|
```go
|
|
// Data saved to ~/.ocean/google/User/
|
|
users := ocean.New[User]("google")
|
|
```
|
|
|
|
You can add as many directory hierarchies as you need but I recommend using a simple `/namespace/collection/` structure.
|