💿 In-memory key value store that saves your data to disk using JSON. 36 Commits
2023-07-09 11:16:08 +02:00
.editorconfig Added explanation 2023-07-05 22:02:16 +02:00
.gitignore Added explanation 2023-07-05 22:02:16 +02:00
Benchmarks_test.go Improved benchmark 2023-07-09 11:16:08 +02:00
Collection_test.go Cleanup 2023-07-08 22:10:02 +02:00
Collection.go Cleanup 2023-07-08 22:10:02 +02:00
Decoder.go Added custom encoding/decoding 2023-07-07 14:38:41 +02:00
DirectoryStorage.go Implemented file storage 2023-07-08 17:26:36 +02:00
Encoder.go Added custom encoding/decoding 2023-07-07 14:38:41 +02:00
Errors.go Improved error handling 2023-07-06 17:26:19 +02:00
FileStorage.go Cleanup 2023-07-08 22:10:02 +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
keyValue.go Implemented file storage 2023-07-08 17:26:36 +02:00
LICENSE Added basic information 2023-07-05 00:20:26 +02:00
README.md Cleanup 2023-07-08 22:10:02 +02:00
Storage.go Implemented file storage 2023-07-08 17:26:36 +02:00

ocean

In-memory key value store that saves your data to disk using JSON.

Installation

go get git.akyoto.dev/go/ocean

Example

// User type
type User struct { Name string }

// Create a new collection
users := ocean.New[User]("todolist")

// Store some data
users.Set("1", &User{Name: "User 1"})
users.Set("2", &User{Name: "User 2"})
users.Set("3", &User{Name: "User 3"})

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

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

Data will be stored in ~/.ocean/todolist/User.dat.

Example file: User.dat

1
{"name":"User 1"}
2
{"name":"User 2"}
3
{"name":"User 3"}

Usage

  1. Create all the collections you need at the start
  2. defer users.Sync() to ensure queued writes will be handled on exit
  3. Start your web server
  4. Retrieve and update your data using Get and Set calls