1 Star 0 Fork 0

艾鸥科技 / go-aiou

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
adapter.go 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
张卓 提交于 2020-05-10 14:55 . init
package database
import (
"gitee.com/aiou-official/go-aiou/core/version"
)
type database interface {
Rules() *version.Rules
Get(key string) (value string)
Put(key, value string)
Has(key string) bool
Del(key string)
}
const (
// StateTable name
StateTable = "state"
)
type chainbaseAdapter struct {
cb IMultiValue
rules *version.Rules
}
func (c *chainbaseAdapter) Rules() *version.Rules {
return c.rules
}
func (c *chainbaseAdapter) Get(key string) (value string) {
var err error
value, err = c.cb.Get(StateTable, key)
if err != nil {
panic(err)
}
if value == "" {
return NilPrefix
}
return
}
func (c *chainbaseAdapter) Put(key, value string) {
err := c.cb.Put(StateTable, key, value)
if err != nil {
panic(err)
}
}
func (c *chainbaseAdapter) Has(key string) bool {
ok, err := c.cb.Has(StateTable, key)
if err != nil {
panic(err)
}
return ok
}
func (c *chainbaseAdapter) Del(key string) {
err := c.cb.Del(StateTable, key)
if err != nil {
panic(err)
}
}
func newChainbaseAdapter(cb IMultiValue, rules *version.Rules) *chainbaseAdapter {
return &chainbaseAdapter{
cb: cb,
rules: rules,
}
}
1
https://gitee.com/aiou-official/go-aiou.git
git@gitee.com:aiou-official/go-aiou.git
aiou-official
go-aiou
go-aiou
376a44096468

搜索帮助