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)
Increments a stat by one.
# File lib/resque/stat.rb, line 35 def <<(stat) incr stat end
Decrements a stat by one.
# File lib/resque/stat.rb, line 48 def >>(stat) decr stat end
Alias of `get`
# File lib/resque/stat.rb, line 22 def [](stat) get(stat) end
Removes a stat from Redis, effectively setting it to 0.
# File lib/resque/stat.rb, line 53 def clear(stat) redis.del("stat:#{stat}") end
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 43 def decr(stat, by = 1) redis.decrby("stat:#{stat}", by) end
Returns the int value of a stat, given a string stat name.
# File lib/resque/stat.rb, line 17 def get(stat) redis.get("stat:#{stat}").to_i end
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 30 def incr(stat, by = 1) redis.incrby("stat:#{stat}", by) end
Direct access to the Redis instance.
# File lib/resque/stat.rb, line 12 def redis Resque.redis end