Module: RunningCount::Storage

Defined in:
lib/running_count/storage.rb

Class Method Summary collapse

Class Method Details

.add_item(item, running_set_name, amount) ⇒ Object



16
17
18
# File 'lib/running_count/storage.rb', line 16

def add_item(item, running_set_name, amount)
  RunningCount.redis.zincrby(running_set_name, amount || 1, item)
end

.clear_item(item, running_set_name) ⇒ Object



20
21
22
# File 'lib/running_count/storage.rb', line 20

def clear_item(item, running_set_name)
  RunningCount.redis.zrem(running_set_name, item)
end

.scores(running_set_name, item = nil) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/running_count/storage.rb', line 8

def scores(running_set_name, item = nil)
  if item
    RunningCount.redis.zscore(running_set_name, item)
  else
    RunningCount.redis.zrange(running_set_name, 0, -1, with_scores: true)
  end
end