Module: Swagger::Commands::Sets

Included in:
Redis
Defined in:
lib/swagger/commands/sets.rb

Constant Summary collapse

KEY_TYPE =
'set'

Instance Method Summary collapse

Instance Method Details

#sadd(set_name, value) ⇒ Object



6
7
8
# File 'lib/swagger/commands/sets.rb', line 6

def sadd(set_name, value)
  sismember(set_name, value) || ResqueValue.create!(:key => set_name.to_s, :key_type => KEY_TYPE, :value => value.to_s)
end

#sismember(set_name, value) ⇒ Object



19
20
21
# File 'lib/swagger/commands/sets.rb', line 19

def sismember(set_name, value)
  ResqueValue.exists?(:key => set_name.to_s, :key_type => KEY_TYPE, :value => value.to_s)
end

#smembers(set_name) ⇒ Object



15
16
17
# File 'lib/swagger/commands/sets.rb', line 15

def smembers(set_name)
  ResqueValue.all(:conditions => {:key => set_name.to_s, :key_type => KEY_TYPE}).map(&:value)
end

#srem(set_name, value) ⇒ Object



10
11
12
13
# File 'lib/swagger/commands/sets.rb', line 10

def srem(set_name, value)
  ResqueValue.delete_all(:key => set_name.to_s, :key_type => KEY_TYPE, :value => value.to_s)
  nil
end