MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / ZScore

Method ZScore

tx_zset.go:454–475  ·  view source on GitHub ↗

ZScore Returns the score of members in a sorted set specified by key in a bucket.

(bucket string, key, value []byte)

Source from the content-addressed store, hash-verified

452
453// ZScore Returns the score of members in a sorted set specified by key in a bucket.
454func (tx *Tx) ZScore(bucket string, key, value []byte) (float64, error) {
455 if err := tx.ZCheck(bucket); err != nil {
456 return 0, err
457 }
458
459 b, err := tx.db.bucketMgr.GetBucket(DataStructureSortedSet, bucket)
460 if err != nil {
461 return 0.0, err
462 }
463
464 var (
465 bucketId = b.Id
466 sortedSet *SortedSet
467 exist bool
468 )
469
470 if sortedSet, exist = tx.db.Index.SortedSet.exist(bucketId); !exist {
471 return 0, ErrBucket
472 }
473
474 return sortedSet.ZScore(string(key), value)
475}
476
477// ZKeys find all keys matching a given pattern in a bucket
478func (tx *Tx) ZKeys(bucket, pattern string, f func(key string) bool) error {

Callers 3

isPendingZSetEntryMethod · 0.45
txZScoreFunction · 0.45
testZScoreFunction · 0.45

Calls 3

ZCheckMethod · 0.95
GetBucketMethod · 0.80
existMethod · 0.80

Tested by 1

txZScoreFunction · 0.36