SCard returns the set cardinality (number of elements) of the set stored in the bucket at given bucket and key.
(bucket string, key []byte)
| 233 | |
| 234 | // SCard returns the set cardinality (number of elements) of the set stored in the bucket at given bucket and key. |
| 235 | func (tx *Tx) SCard(bucket string, key []byte) (int, error) { |
| 236 | if err := tx.checkTxIsClosed(); err != nil { |
| 237 | return 0, err |
| 238 | } |
| 239 | b, err := tx.db.bucketMgr.GetBucket(DataStructureSet, bucket) |
| 240 | if err != nil { |
| 241 | return 0, err |
| 242 | } |
| 243 | bucketId := b.Id |
| 244 | if set, ok := tx.db.Index.Set.exist(bucketId); ok { |
| 245 | return set.SCard(string(key)), nil |
| 246 | } |
| 247 | |
| 248 | return 0, ErrBucketNotFound |
| 249 | } |
| 250 | |
| 251 | // SDiffByOneBucket returns the members of the set resulting from the difference |
| 252 | // between the first set and all the successive sets in one bucket. |