mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-25 16:15:17 +00:00
38 lines
778 B
Go
38 lines
778 B
Go
|
// Copyright 2020 The LevelDB-Go and Pebble Authors. All rights reserved. Use
|
||
|
// of this source code is governed by a BSD-style license that can be found in
|
||
|
// the LICENSE file.
|
||
|
|
||
|
package pebble_test
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
|
||
|
"github.com/cockroachdb/pebble"
|
||
|
"github.com/cockroachdb/pebble/vfs"
|
||
|
)
|
||
|
|
||
|
func Example() {
|
||
|
db, err := pebble.Open("", &pebble.Options{FS: vfs.NewMem()})
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
key := []byte("hello")
|
||
|
if err := db.Set(key, []byte("world"), pebble.Sync); err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
value, closer, err := db.Get(key)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
fmt.Printf("%s %s\n", key, value)
|
||
|
if err := closer.Close(); err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
if err := db.Close(); err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
// Output:
|
||
|
// hello world
|
||
|
}
|