本文整理汇总了Golang中github.com/ryandotsmith/l2met/bucket.Id.Decode方法的典型用法代码示例。如果您正苦于以下问题:Golang Id.Decode方法的具体用法?Golang Id.Decode怎么用?Golang Id.Decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ryandotsmith/l2met/bucket.Id
的用法示例。
在下文中一共展示了Id.Decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Scan
func (s *RedisStore) Scan(schedule time.Time) (<-chan *bucket.Bucket, error) {
retBuckets := make(chan *bucket.Bucket)
p, err := s.lockPartition()
if err != nil {
return retBuckets, err
}
partition := partitionPrefix + "." + strconv.Itoa(int(p))
go func(out chan *bucket.Bucket) {
rc := s.redisPool.Get()
defer rc.Close()
defer close(out)
defer s.unlockPartition(p)
rc.Send("MULTI")
rc.Send("SMEMBERS", partition)
rc.Send("DEL", partition)
reply, err := redis.Values(rc.Do("EXEC"))
if err != nil {
fmt.Printf("at=%q error=%s\n", "bucket-store-scan", err)
return
}
var delCount int64
var members []string
redis.Scan(reply, &members, &delCount)
for _, member := range members {
id := new(bucket.Id)
err := id.Decode(bytes.NewBufferString(member))
if err != nil {
fmt.Printf("at=%q error=%s\n",
"bucket-store-parse-key", err)
continue
}
bucketReady := id.Time.Add(id.Resolution)
if !bucketReady.After(schedule) {
out <- &bucket.Bucket{Id: id}
} else {
if err := s.putback(id); err != nil {
fmt.Printf("putback-error=%s\n", err)
}
}
}
}(retBuckets)
return retBuckets, nil
}