Skip to content

Commit

Permalink
docs: readme initalization
Browse files Browse the repository at this point in the history
  • Loading branch information
xtlsoft committed Aug 30, 2020
1 parent a71e4cc commit 324fbcf
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,59 @@
(sub project of apiles)

Simple KV memory middleware library (for Golang).

## Installation

```bash
go get github.com/apiles/unikv
```

## Usage

First import packages:

```go
import (
"github.com/apiles/unikv"
_ "github.com/apiles/unikv/drivers"
)
```

Note that `github.com/apiles/unikv/drivers` contains all the available drivers.

You can specify that with importing `github.com/apiles/unikv/memory` or something.

Available drivers:

| name | address |
| ------ | -------------------------------- |
| memory | `github.com/apiles/unikv/memory` |
| redis | `github.com/apiles/unikv/redis` |

Then you need to specify an `unikv.yml`. An example is included in [docs/unikv.yml](docs/unikv.yml).

Note that unikv will look it up in the current work directory. You can also specify it by setting the environment varaible `UNIKV_CONFIGURE`.

Then you can see this example:

```go
func main() {
ns := unikv.NewNamespace("hello")
bucket, err := ns.NewBucket("new")
if err != nil {
panic(err)
}
bucket.PutString("hello", "world")
bucket.PutInt("new", 1234)
bucket.Put("c", true)
var c bool
bucket.Get("c", &c)
value, _ := bucket.GetString("hello")
in, _ := bucket.GetInt("new")
fmt.Println(value, in, c)
}
```

## API Docs

Go to <https://pkg.go.dev/github.com/apiles/unikv>.
File renamed without changes.
11 changes: 10 additions & 1 deletion docs/unikv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@ namespaces:
main:
prefix: main
driver: memory
context: {}
testredis:
prefix: easy
driver: redis
context:
buffer: 12
server: redis://127.0.0.1:6379
options:
username: string
password: string
tls: true
database: 0
1 change: 1 addition & 0 deletions drivers/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package drivers

import (
_ "github.com/apiles/unikv/drivers/memory"
_ "github.com/apiles/unikv/drivers/redis"
)

0 comments on commit 324fbcf

Please sign in to comment.