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

Method SRem

tx_set.go:96–117  ·  view source on GitHub ↗

SRem removes the specified members from the set stored int the bucket at given bucket,key and items.

(bucket string, key []byte, items ...[]byte)

Source from the content-addressed store, hash-verified

94
95// SRem removes the specified members from the set stored int the bucket at given bucket,key and items.
96func (tx *Tx) SRem(bucket string, key []byte, items ...[]byte) error {
97 if err := tx.checkTxIsClosed(); err != nil {
98 return err
99 }
100
101 b, err := tx.db.bucketMgr.GetBucket(DataStructureSet, bucket)
102 if err != nil {
103 return err
104 }
105 bucketId := b.Id
106 if set, ok := tx.db.Index.Set.exist(bucketId); ok {
107 ok, err := set.SAreMembers(string(key), items...)
108 if err != nil {
109 return err
110 }
111 if !ok {
112 return ErrSetMemberNotExist
113 }
114 return tx.sPut(bucket, key, DataDeleteFlag, items...)
115 }
116 return ErrBucketNotFound
117}
118
119// SAreMembers returns if the specified members are the member of the set int the bucket at given bucket,key and items.
120func (tx *Tx) SAreMembers(bucket string, key []byte, items ...[]byte) (bool, error) {

Callers 4

buildSetIdxMethod · 0.45
txSRemFunction · 0.45
SMoveByTwoBucketsMethod · 0.45
testSRemFunction · 0.45

Calls 5

checkTxIsClosedMethod · 0.95
sPutMethod · 0.95
GetBucketMethod · 0.80
existMethod · 0.80
SAreMembersMethod · 0.45

Tested by 1

txSRemFunction · 0.36