# ocean In-memory key value store that saves your data to disk using JSON. ## Installation ```shell go get git.akyoto.dev/go/ocean ``` ## Example ```go // User type type User struct { Name string } // Create a new collection todolist := ocean.New("todolist") users := todolist.NewCollection[User](&storage.File[User]{}) // 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`. ## Format ```json 1 {"name":"User 1"} 2 {"name":"User 2"} 3 {"name":"User 3"} ``` ## Benchmarks ``` BenchmarkGet-12 275126157 4.462 ns/op 0 B/op 0 allocs/op BenchmarkSet-12 4796011 251.0 ns/op 32 B/op 2 allocs/op BenchmarkDelete-12 471913158 2.530 ns/op 0 B/op 0 allocs/op BenchmarkNew-12 48838576 22.89 ns/op 80 B/op 1 allocs/op ``` ## 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