本文整理汇总了Golang中github.com/chop-dbhi/origins/storage.Tx类的典型用法代码示例。如果您正苦于以下问题:Golang Tx类的具体用法?Golang Tx怎么用?Golang Tx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tx类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetSegment
// GetSegment returns a segment from storage.
func GetSegment(e storage.Tx, domain string, id *uuid.UUID) (*Segment, error) {
var (
bytes []byte
err error
key string
)
key = fmt.Sprintf(segmentKey, id)
if bytes, err = e.Get(domain, key); err != nil {
return nil, err
}
if bytes == nil {
return nil, nil
}
seg := Segment{
UUID: id,
Domain: domain,
}
if err = unmarshalSegment(bytes, &seg); err != nil {
return nil, err
}
return &seg, nil
}
开发者ID:l-k-,项目名称:origins,代码行数:29,代码来源:methods.go
示例2: SetBlock
func SetBlock(e storage.Tx, domain string, id *uuid.UUID, idx int, bytes []byte) (int, error) {
var key string
key = fmt.Sprintf(blockKey, id, idx)
return len(bytes), e.Set(domain, key, bytes)
}
开发者ID:l-k-,项目名称:origins,代码行数:7,代码来源:methods.go
示例3: GetLog
func GetLog(e storage.Tx, domain, name string) (*Log, error) {
var (
bytes []byte
err error
key string
)
key = fmt.Sprintf(logKey, name)
if bytes, err = e.Get(domain, key); err != nil {
return nil, err
}
if bytes == nil {
return nil, nil
}
log := Log{
Domain: domain,
Name: name,
}
if err = unmarshalLog(bytes, &log); err != nil {
return nil, err
}
return &log, nil
}
开发者ID:l-k-,项目名称:origins,代码行数:28,代码来源:methods.go
示例4: GetBlock
// GetBlock returns a block from storage. The lookup requires the domain, ID of the segment
// the block is contained in, the index of the block in the segment, and the transaction
// that processed the segment.
func GetBlock(e storage.Tx, domain string, id *uuid.UUID, idx int) ([]byte, error) {
var key string
key = fmt.Sprintf(blockKey, id, idx)
return e.Get(domain, key)
}
开发者ID:l-k-,项目名称:origins,代码行数:10,代码来源:methods.go
示例5: SetLog
func SetLog(e storage.Tx, domain string, log *Log) (int, error) {
var (
bytes []byte
err error
key string
)
if bytes, err = marshalLog(log); err != nil {
return 0, err
}
key = fmt.Sprintf(logKey, log.Name)
return len(bytes), e.Set(domain, key, bytes)
}
开发者ID:l-k-,项目名称:origins,代码行数:15,代码来源:methods.go
示例6: SetSegment
func SetSegment(e storage.Tx, domain string, segment *Segment) (int, error) {
var (
bytes []byte
err error
key string
)
if bytes, err = marshalSegment(segment); err != nil {
return 0, err
}
key = fmt.Sprintf(segmentKey, segment.UUID)
return len(bytes), e.Set(domain, key, bytes)
}
开发者ID:l-k-,项目名称:origins,代码行数:15,代码来源:methods.go
示例7: DeleteLog
func DeleteLog(e storage.Tx, domain string, name string) error {
key := fmt.Sprintf(logKey, name)
return e.Delete(domain, key)
}
开发者ID:l-k-,项目名称:origins,代码行数:5,代码来源:methods.go
示例8: DeleteBlock
func DeleteBlock(e storage.Tx, domain string, id *uuid.UUID, idx int) error {
key := fmt.Sprintf(blockKey, id, idx)
return e.Delete(domain, key)
}
开发者ID:l-k-,项目名称:origins,代码行数:5,代码来源:methods.go
示例9: DeleteSegment
func DeleteSegment(e storage.Tx, domain string, id *uuid.UUID) error {
key := fmt.Sprintf(segmentKey, id)
return e.Delete(domain, key)
}
开发者ID:l-k-,项目名称:origins,代码行数:5,代码来源:methods.go
示例10: txid
// txid increments a global transaction ID.
func txid(tx storage.Tx) (uint64, error) {
return tx.Incr("origins", "tx")
}
开发者ID:l-k-,项目名称:origins,代码行数:4,代码来源:transact.go
注:本文中的github.com/chop-dbhi/origins/storage.Tx类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论