module Resque::Stat
The stat subsystem. Used to keep track of integer counts.
Get a stat: Stat[name] Incr a stat: Stat.incr(name) Decr a stat: Stat.decr(name) Kill a stat: Stat.clear(name)
Public Instance Methods
<<(stat)
click to toggle source
Increments a stat by one.
# File lib/resque/stat.rb, line 43 def <<(stat) incr stat end
>>(stat)
click to toggle source
Decrements a stat by one.
# File lib/resque/stat.rb, line 56 def >>(stat) decr stat end
[](stat)
click to toggle source
Alias of `get`
# File lib/resque/stat.rb, line 30 def [](stat) get(stat) end
clear(stat)
click to toggle source
Removes a stat from Redis, effectively setting it to 0.
# File lib/resque/stat.rb, line 61 def clear(stat) data_store.clear_stat(stat) end
data_store()
click to toggle source
# File lib/resque/stat.rb, line 16 def data_store @data_store ||= Resque.redis end
data_store=(data_store)
click to toggle source
# File lib/resque/stat.rb, line 20 def data_store=(data_store) @data_store = data_store end
decr(stat, by = 1)
click to toggle source
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.
# File lib/resque/stat.rb, line 51 def decr(stat, by = 1) data_store.decrement_stat(stat,by) end
get(stat)
click to toggle source
Returns the int value of a stat, given a string stat name.
# File lib/resque/stat.rb, line 25 def get(stat) data_store.stat(stat) end
incr(stat, by = 1)
click to toggle source
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.
# File lib/resque/stat.rb, line 38 def incr(stat, by = 1) data_store.increment_stat(stat,by) end
redis()
click to toggle source
# File lib/resque/stat.rb, line 11 def redis warn '[Resque] [Deprecation] Resque::Stat #redis method is deprecated (please use #data_strore)' data_store end