ZScore Returns the score of members in a sorted set specified by key in a bucket.
(bucket string, key, value []byte)
| 452 | |
| 453 | // ZScore Returns the score of members in a sorted set specified by key in a bucket. |
| 454 | func (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 |
| 478 | func (tx *Tx) ZKeys(bucket, pattern string, f func(key string) bool) error { |