33 lines
795 B
Markdown
Raw Normal View History

2023-07-04 21:35:20 +00:00
# ocean
2023-07-05 20:07:43 +00:00
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.
2023-07-06 12:34:22 +00:00
Let's say we use this struct to save our user data:
2023-07-06 12:10:12 +00:00
```go
2023-07-06 12:31:23 +00:00
type User struct {
Name string
}
2023-07-06 12:34:22 +00:00
```
2023-07-06 12:31:23 +00:00
2023-07-06 12:34:22 +00:00
Then we can create a typesafe collection using Go generics:
```go
2023-07-06 12:27:48 +00:00
// Data saved to ~/.ocean/User/
2023-07-06 12:31:23 +00:00
users := ocean.New[User]("User")
// Store key and value in memory and write ~/.ocean/User/1.json
2023-07-06 12:10:12 +00:00
users.Set("1", &User{Name: "User 1"})
```
2023-07-06 12:27:48 +00:00
2023-07-06 12:34:22 +00:00
In a real project you would usually prefix your collections with a project or company name:
2023-07-06 12:27:48 +00:00
```go
// Data saved to ~/.ocean/google/User/
2023-07-06 12:34:22 +00:00
users := ocean.New[User]("google", "User")
2023-07-06 12:27:48 +00:00
```
You can add as many hierarchies as you need but I recommend using a simple `/namespace/collection/` structure.