Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
manosriram committed May 4, 2024
1 parent e22c98f commit 3732db2
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ defer d.Close()

#### Set
```go
kvPair := &nimbusdb.KeyValuePair{
Key: []byte("key"),
Value: []byte("value"),
Ttl: 5 * time.Minute, // Optional, default is 1 week
setValue, err := d.Set([]byte("key"), []byte("value"))
if err != nil {
// handle error
}
setValue, err := d.Set(kvPair)
```

#### Set with expiry
```go
setValue, err := d.SetWithTTL([]byte("key"), []byte("value"), time.Second * 10)
if err != nil {
// handle error
}
Expand Down Expand Up @@ -182,21 +185,17 @@ func main() {

go watchEvents(watchChannel)

kvPair := &nimbusdb.KeyValuePair{
Key: []byte("key"),
Value: []byte("value"),
}
setValue, err := d.Set(kvPair) // will trigger an CREATE event
setValue, err := d.Set([]byte("key"), []byte("value")) // will trigger an CREATE event
if err != nil {
// handle error
}

setValue, err := d.Set(kvPair) // will trigger an UPDATE event
setValue, err := d.Set([]byte("key"), []byte("value")) // will trigger an UPDATE event
if err != nil {
// handle error
}

err = d.Delete(kvPair.Key) // will trigger an DELETE event
err = d.Delete([]byte("key")) // will trigger an DELETE event
if err != nil {
// handle error
}
Expand Down

0 comments on commit 3732db2

Please sign in to comment.