Module: Resque::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
(also: #data_store)
Direct access to the Redis instance.
Instance Method Details
#<<(stat) ⇒ Object
Increments a stat by one.
36 37 38 |
# File 'lib/resque/stat.rb', line 36 def <<(stat) incr stat end |
#>>(stat) ⇒ Object
Decrements a stat by one.
49 50 51 |
# File 'lib/resque/stat.rb', line 49 def >>(stat) decr stat end |
#[](stat) ⇒ Object
Alias of ‘get`
23 24 25 |
# File 'lib/resque/stat.rb', line 23 def [](stat) get(stat) end |
#clear(stat) ⇒ Object
Removes a stat from Redis, effectively setting it to 0.
54 55 56 |
# File 'lib/resque/stat.rb', line 54 def clear(stat) data_store.clear_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.
44 45 46 |
# File 'lib/resque/stat.rb', line 44 def decr(stat, by = 1) data_store.decremet_stat(stat,by) end |
#get(stat) ⇒ Object
Returns the int value of a stat, given a string stat name.
18 19 20 |
# File 'lib/resque/stat.rb', line 18 def get(stat) data_store.stat(stat) 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.
31 32 33 |
# File 'lib/resque/stat.rb', line 31 def incr(stat, by = 1) data_store.increment_stat(stat,by) end |