-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fea21e3
commit 02209f2
Showing
6 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
commit-message: | ||
prefix: "deps:" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "sunday" | ||
time: "09:00" | ||
- package-ecosystem: "github-actions" | ||
commit-message: | ||
prefix: "ci:" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "sunday" | ||
time: "09:00" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
schedule: | ||
- cron: '0 0 * * 0' # run "At 00:00 on Sunday" | ||
|
||
# See https://github.com/cristalhq/.github/ | ||
jobs: | ||
build: | ||
uses: cristalhq/.github/.github/workflows/[email protected] | ||
|
||
vuln: | ||
uses: cristalhq/.github/.github/workflows/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Guide for kvstore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
# kvstore | ||
Key-value store abstraction in Go | ||
|
||
[![build-img]][build-url] | ||
[![pkg-img]][pkg-url] | ||
[![version-img]][version-url] | ||
|
||
Key-value store abstraction in Go. | ||
|
||
## Features | ||
|
||
* Simple. | ||
* Dependency-free. | ||
|
||
See [docs][pkg-url] and [GUIDE.md](https://github.com/go-distsys/kvstore/blob/main/GUIDE.md) for more details. | ||
|
||
## Install | ||
|
||
Go version 1.18+ | ||
|
||
``` | ||
go get github.com/go-distsys/kvstore | ||
``` | ||
|
||
## Example | ||
|
||
```go | ||
TODO | ||
``` | ||
|
||
See [example_test.go](https://github.com/go-distsys/kvstore/blob/main/example_test.go). | ||
|
||
## License | ||
|
||
[MIT License](LICENSE). | ||
|
||
[build-img]: https://github.com/go-distsys/kvstore/workflows/build/badge.svg | ||
[build-url]: https://github.com/go-distsys/kvstore/actions | ||
[pkg-img]: https://pkg.go.dev/badge/go-distsys/kvstore | ||
[pkg-url]: https://pkg.go.dev/github.com/go-distsys/kvstore | ||
[version-img]: https://img.shields.io/github/v/release/go-distsys/kvstore | ||
[version-url]: https://github.com/go-distsys/kvstore/releases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/go-distsys/kvstore | ||
|
||
go 1.18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package kvstore | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
) | ||
|
||
// Store represents the key-value storage. | ||
type Store interface { | ||
Put(ctx context.Context, key string, value []byte) error | ||
Get(ctx context.Context, key string) (*Pair, error) | ||
Delete(ctx context.Context, key string) error | ||
Exists(ctx context.Context, key string) (bool, error) | ||
} | ||
|
||
// AtomicStore represents the key-value storage that supports atomic operations. | ||
type AtomicStore interface { | ||
AtomicPut(ctx context.Context, key string, value []byte, prev *Pair) (bool, *Pair, error) | ||
AtomicGet(ctx context.Context, key string) (*Pair, error) | ||
AtomicDelete(ctx context.Context, key string, prev *Pair) (bool, error) | ||
} | ||
|
||
// WatchStore represents the key-value storage that supports watch operations. | ||
type WatchStore interface { | ||
Watch(ctx context.Context, key string) (<-chan *Pair, error) | ||
WatchTree(ctx context.Context, prefix string) (<-chan []*Pair, error) | ||
} | ||
|
||
// Pair stored in key-value storage. | ||
type Pair struct { | ||
Key string | ||
Value []byte | ||
} | ||
|
||
// Key-value storage errors. | ||
var ( | ||
ErrKeyNotFound = errors.New("key not found") | ||
) |