本文整理匯總了Golang中github.com/pressly/chainstore.Store.Close方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.Close方法的具體用法?Golang Store.Close怎麽用?Golang Store.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pressly/chainstore.Store
的用法示例。
在下文中一共展示了Store.Close方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestS3Store
func TestS3Store(t *testing.T) {
var store chainstore.Store
var err error
ctx := context.Background()
assert := assert.New(t)
store = chainstore.New(New(bucketID, accessKey, secretKey))
err = store.Open()
assert.Nil(err)
defer store.Close()
// Put a bunch of objects
e1 := store.Put(ctx, "hi", []byte{1, 2, 3})
e2 := store.Put(ctx, "bye", []byte{4, 5, 6})
assert.Nil(e1)
assert.Nil(e2)
// Get those objects
v1, _ := store.Get(ctx, "hi")
v2, _ := store.Get(ctx, "bye")
assert.Equal(v1, []byte{1, 2, 3})
assert.Equal(v2, []byte{4, 5, 6})
// Delete those objects
e1 = store.Del(ctx, "hi")
e2 = store.Del(ctx, "bye")
assert.Equal(e1, nil)
assert.Equal(e2, nil)
}
示例2: TestMetricsMgrStore
func TestMetricsMgrStore(t *testing.T) {
var store chainstore.Store
var err error
ctx := context.Background()
assert := assert.New(t)
store = chainstore.New(New("ns"))
err = store.Open()
assert.Nil(err)
defer store.Close()
// Put a bunch of objects
e1 := store.Put(ctx, "hi", []byte{1, 2, 3})
e2 := store.Put(ctx, "bye", []byte{4, 5, 6})
assert.Nil(e1)
assert.Nil(e2)
// Delete those objects
e1 = store.Del(ctx, "hi")
e2 = store.Del(ctx, "bye")
assert.Equal(e1, nil)
assert.Equal(e2, nil)
}
示例3: TestBoltStore
func TestBoltStore(t *testing.T) {
var store chainstore.Store
var err error
store = boltstore.New(chainstore.TempDir()+"/test.db", "test")
err = store.Open()
if err != nil {
t.Error(err)
}
defer store.Close() // does this get called?
Convey("Boltdb Open", t, func() {
Convey("Put a bunch of objects", func() {
e1 := store.Put("hi", []byte{1, 2, 3})
e2 := store.Put("bye", []byte{4, 5, 6})
So(e1, ShouldEqual, nil)
So(e2, ShouldEqual, nil)
})
Convey("Get those objects", func() {
v1, _ := store.Get("hi")
v2, _ := store.Get("bye")
So(v1, ShouldResemble, []byte{1, 2, 3})
So(v2, ShouldResemble, []byte{4, 5, 6})
})
Convey("Delete those objects", func() {
e1 := store.Del("hi")
e2 := store.Del("bye")
So(e1, ShouldEqual, nil)
So(e2, ShouldEqual, nil)
v, _ := store.Get("hi")
So(len(v), ShouldEqual, 0)
})
})
}
示例4: TestBoltStore
func TestBoltStore(t *testing.T) {
var store chainstore.Store
var err error
ctx := context.Background()
store = chainstore.New(New(tempDir()+"/test.db", "test"))
assert := assert.New(t)
err = store.Open()
assert.Nil(err)
defer store.Close() // does this get called?
// Put a bunch of objects
e1 := store.Put(ctx, "hi", []byte{1, 2, 3})
e2 := store.Put(ctx, "bye", []byte{4, 5, 6})
assert.Equal(e1, nil)
assert.Equal(e2, nil)
// Get those objects
v1, _ := store.Get(ctx, "hi")
v2, _ := store.Get(ctx, "bye")
assert.Equal(v1, []byte{1, 2, 3})
assert.Equal(v2, []byte{4, 5, 6})
// Delete those objects
e1 = store.Del(ctx, "hi")
e2 = store.Del(ctx, "bye")
assert.Equal(e1, nil)
assert.Equal(e2, nil)
v, _ := store.Get(ctx, "hi")
assert.Equal(len(v), 0)
}
示例5: TestLevelStore
func TestLevelStore(t *testing.T) {
var store chainstore.Store
var err error
store = levelstore.New(chainstore.TempDir())
err = store.Open()
if err != nil {
t.Error(err)
}
defer store.Close()
Convey("Leveldb Open", t, func() {
Convey("Put a bunch of objects", func() {
e1 := store.Put("hi", []byte{1, 2, 3})
e2 := store.Put("bye", []byte{4, 5, 6})
So(e1, ShouldEqual, nil)
So(e2, ShouldEqual, nil)
})
Convey("Get those objects", func() {
v1, _ := store.Get("hi")
v2, _ := store.Get("bye")
So(v1, ShouldResemble, []byte{1, 2, 3})
So(v2, ShouldResemble, []byte{4, 5, 6})
})
Convey("Delete those objects", func() {
e1 := store.Del("hi")
e2 := store.Del("bye")
So(e1, ShouldEqual, nil)
So(e2, ShouldEqual, nil)
})
})
}