Module: ResqueSqs::Stat
Overview
Instance Method Summary collapse
-
#<<(stat) ⇒ Object
Increments a stat by one.
-
#>>(stat) ⇒ Object
Decrements a stat by one.
-
#[](stat) ⇒ Object
Alias of ‘get`.
-
#clear(stat) ⇒ Object
Removes a stat from Redis, effectively setting it to 0.
-
#decr(stat, by = 1) ⇒ Object
For a string stat name, decrements the stat by one.
-
#get(stat) ⇒ Object
Returns the int value of a stat, given a string stat name.
-
#incr(stat, by = 1) ⇒ Object
For a string stat name, increments the stat by one.
-
#redis ⇒ Object
Direct access to the Redis instance.
Instance Method Details
#<<(stat) ⇒ Object
Increments a stat by one.
35 36 37 |
# File 'lib/resque_sqs/stat.rb', line 35 def <<(stat) incr stat end |
#>>(stat) ⇒ Object
Decrements a stat by one.
48 49 50 |
# File 'lib/resque_sqs/stat.rb', line 48 def >>(stat) decr stat end |
#[](stat) ⇒ Object
Alias of ‘get`
22 23 24 |
# File 'lib/resque_sqs/stat.rb', line 22 def [](stat) get(stat) end |
#clear(stat) ⇒ Object
Removes a stat from Redis, effectively setting it to 0.
53 54 55 |
# File 'lib/resque_sqs/stat.rb', line 53 def clear(stat) redis.del("stat:#{stat}") end |
#decr(stat, by = 1) ⇒ Object
For a string stat name, decrements the stat by one.
Can optionally accept a second int parameter. The stat is then decremented by that amount.
43 44 45 |
# File 'lib/resque_sqs/stat.rb', line 43 def decr(stat, by = 1) redis.decrby("stat:#{stat}", by) end |
#get(stat) ⇒ Object
Returns the int value of a stat, given a string stat name.
17 18 19 |
# File 'lib/resque_sqs/stat.rb', line 17 def get(stat) redis.get("stat:#{stat}").to_i end |
#incr(stat, by = 1) ⇒ Object
For a string stat name, increments the stat by one.
Can optionally accept a second int parameter. The stat is then incremented by that amount.
30 31 32 |
# File 'lib/resque_sqs/stat.rb', line 30 def incr(stat, by = 1) redis.incrby("stat:#{stat}", by) end |