# ocean In-memory key value store that saves your data in JSON format. ``` 1 {"name":"User 1"} 2 {"name":"User 2"} 3 {"name":"User 3"} ``` If you like, you can operate on your entire data with classic UNIX tools. ## Installation ```shell go get git.akyoto.dev/go/ocean ``` ## Example ```go // User data type User struct { Name string } // Load existing data from ~/.ocean/User.dat users := ocean.New[User]() // Store in memory and also store in ~/.ocean/User.dat users.Set("1", &User{Name: "User 1"}) // Read from memory first, 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: ```go // Data saved to ~/.ocean/google/User.dat users := ocean.New[User]("google") ``` Disk writes are async and they work like this: 1. Set key and value in memory (sync.Map.Store) 2. Mark the collection as "dirty" (atomic.StoreUint32) 3. Immediately return control to the program Because a `Set` call doesn't immediately flush the memory to disk, calling `Set` multiple times in a web server request becomes extremely efficient.