https://github.com/bborbe/memorykv
https://github.com/bborbe/memorykv
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bborbe/memorykv
- Owner: bborbe
- License: bsd-2-clause
- Created: 2024-01-29T16:43:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-12-05T22:34:10.000Z (6 months ago)
- Last Synced: 2025-12-09T12:30:20.026Z (6 months ago)
- Language: Go
- Size: 5.94 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# memorykv
In-memory key-value store implementing `github.com/bborbe/kv` interface.
## Installation
```bash
go get github.com/bborbe/memorykv
```
## Usage
```go
package main
import (
"context"
"github.com/bborbe/kv/libkv"
"github.com/bborbe/memorykv"
)
func main() {
ctx := context.Background()
// Open in-memory database
db, err := memorykv.OpenMemory(ctx)
if err != nil {
panic(err)
}
defer db.Close(ctx)
// Use within transactions
err = db.Update(ctx, func(ctx context.Context, tx libkv.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(ctx, []byte("my-bucket"))
if err != nil {
return err
}
return bucket.Put(ctx, []byte("key"), []byte("value"))
})
}
```
Perfect for testing and development where you need a lightweight, ephemeral key-value store that's compatible with other `github.com/bborbe/kv` implementations.