本文整理汇总了Golang中github.com/wandoulabs/rpdb/pkg/store.Batch.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang Batch.Set方法的具体用法?Golang Batch.Set怎么用?Golang Batch.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wandoulabs/rpdb/pkg/store.Batch
的用法示例。
在下文中一共展示了Batch.Set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: storeObject
func (o *stringRow) storeObject(b *Rpdb, bt *store.Batch, expireat uint64, obj interface{}) error {
value, ok := obj.(rdb.String)
if !ok || len(value) == 0 {
return errors.Trace(ErrObjectValue)
}
o.ExpireAt, o.Value = expireat, value
bt.Set(o.DataKey(), o.DataValue())
bt.Set(o.MetaKey(), o.MetaValue())
return nil
}
示例2: storeObject
func (o *setRow) storeObject(b *Rpdb, bt *store.Batch, expireat uint64, obj interface{}) error {
set, ok := obj.(rdb.Set)
if !ok || len(set) == 0 {
return errors.Trace(ErrObjectValue)
}
for i, m := range set {
if len(m) != 0 {
continue
}
return errArguments("set[%d], len(member) = %d", i, len(m))
}
ms := &markSet{}
for _, o.Member = range set {
ms.Set(o.Member)
bt.Set(o.DataKey(), o.DataValue())
}
o.Size, o.ExpireAt = ms.Len(), expireat
bt.Set(o.MetaKey(), o.MetaValue())
return nil
}
示例3: storeObject
func (o *listRow) storeObject(b *Rpdb, bt *store.Batch, expireat uint64, obj interface{}) error {
list, ok := obj.(rdb.List)
if !ok || len(list) == 0 {
return errors.Trace(ErrObjectValue)
}
for i, e := range list {
if len(e) != 0 {
continue
}
return errArguments("list[%d], len(value) = %d", i, len(e))
}
for i, value := range list {
o.Index, o.Value = int64(i), value
bt.Set(o.DataKey(), o.DataValue())
}
o.Lindex, o.Rindex = 0, int64(len(list))
o.ExpireAt = expireat
bt.Set(o.MetaKey(), o.MetaValue())
return nil
}
示例4: storeObject
func (o *hashRow) storeObject(b *Rpdb, bt *store.Batch, expireat uint64, obj interface{}) error {
hash, ok := obj.(rdb.Hash)
if !ok || len(hash) == 0 {
return errors.Trace(ErrObjectValue)
}
for i, e := range hash {
if e == nil {
return errArguments("hash[%d] is nil", i)
}
if len(e.Field) == 0 || len(e.Value) == 0 {
return errArguments("hash[%d], len(field) = %d, len(value) = %d", i, len(e.Field), len(e.Value))
}
}
ms := &markSet{}
for _, e := range hash {
o.Field, o.Value = e.Field, e.Value
ms.Set(o.Field)
bt.Set(o.DataKey(), o.DataValue())
}
o.Size, o.ExpireAt = ms.Len(), expireat
bt.Set(o.MetaKey(), o.MetaValue())
return nil
}
示例5: storeObject
func (o *zsetRow) storeObject(b *Rpdb, bt *store.Batch, expireat uint64, obj interface{}) error {
zset, ok := obj.(rdb.ZSet)
if !ok || len(zset) == 0 {
return errors.Trace(ErrObjectValue)
}
for i, e := range zset {
if e == nil {
return errArguments("zset[%d] is nil", i)
}
if len(e.Member) == 0 {
return errArguments("zset[%d], len(member) = %d", i, len(e.Member))
}
}
ms := &markSet{}
for _, e := range zset {
o.Member, o.Score = e.Member, e.Score
ms.Set(o.Member)
bt.Set(o.DataKey(), o.DataValue())
}
o.Size, o.ExpireAt = ms.Len(), expireat
bt.Set(o.MetaKey(), o.MetaValue())
return nil
}