SPop removes and returns one or more random elements from the set value store at key.
(key string)
| 93 | |
| 94 | // SPop removes and returns one or more random elements from the set value store at key. |
| 95 | func (s *Set) SPop(key string) *core.Record { |
| 96 | if !s.SHasKey(key) { |
| 97 | return nil |
| 98 | } |
| 99 | |
| 100 | for hash, record := range s.M[key] { |
| 101 | delete(s.M[key], hash) |
| 102 | return record |
| 103 | } |
| 104 | |
| 105 | return nil |
| 106 | } |
| 107 | |
| 108 | // SCard Returns the set cardinality (number of elements) of the set stored at key. |
| 109 | func (s *Set) SCard(key string) int { |