Files
cloud-services/pkg/redis/set.go

26 lines
468 B
Go

package redis
// Set represents a set object using a map of empty structs
type Set map[string]void
type void struct{}
var member void
// Add id to the set, returns false if id exists
func (s Set) Add(id string) bool {
if _, ok := s[id]; ok {
return false
}
s[id] = member
return true
}
// Remove id from the set, return false if id doesn't exist
func (s Set) Remove(id string) bool {
if _, ok := s[id]; !ok {
return false
}
delete(s, id)
return true
}