本文整理匯總了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
}