💿 In-memory key value store that saves your data to disk using JSON.
Go to file
2023-07-06 23:46:47 +02:00
.editorconfig Added explanation 2023-07-05 22:02:16 +02:00
.gitignore Added explanation 2023-07-05 22:02:16 +02:00
Collection_test.go Added filter function 2023-07-06 23:46:47 +02:00
Collection.go Added filter function 2023-07-06 23:46:47 +02:00
Errors.go Improved error handling 2023-07-06 17:26:19 +02:00
go.mod Added basic tests 2023-07-05 17:23:50 +02:00
go.sum Added basic tests 2023-07-05 17:23:50 +02:00
LICENSE Added basic information 2023-07-05 00:20:26 +02:00
README.md Added benchmarks 2023-07-06 19:40:33 +02:00

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.

Installation

go get git.akyoto.dev/go/ocean

Example

// 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
users.Set("1", &User{Name: "User 1"})

// Read from memory
firstUser, err := users.Get("1")

// Iterate over all users
for user := range users.All() {
    fmt.Println(user.Name)
}

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")

You can add as many directory hierarchies as you need but I recommend using a simple /namespace/collection/ structure.

Limitations

  • Keys cannot be empty and they cannot contain a directory separator like /.

  • This storage mechanism is only suitable for small to medium data volume.

Ocean isn't meant to be used for big data, however the package is very lightweight so you can combine it with a big data store.