Module: Kthxbye::Stats
Instance Method Summary (collapse)
-
- (Object) decr(stat, by = 1)
decrement a count by a given value (defaults to 1).
-
- (Object) get(stat)
(also: #[])
get count for a given stat (can also use [] method).
-
- (Object) incr(stat, by = 1)
increment a count by a given value (defaults to 1).
-
- (Object) reset(stat)
reset this stat to 0.
Methods included from Helper
Instance Method Details
- (Object) decr(stat, by = 1)
decrement a count by a given value (defaults to 1)
29 30 31 |
# File 'lib/kthxbye/stats.rb', line 29 def decr( stat, by=1 ) redis.decrby("stat:#{stat}", by) end |
- (Object) get(stat) Also known as: []
get count for a given stat (can also use [] method)
18 19 20 |
# File 'lib/kthxbye/stats.rb', line 18 def get( stat ) redis.get( "stat:#{stat}" ).to_i end |
- (Object) incr(stat, by = 1)
increment a count by a given value (defaults to 1)
24 25 26 |
# File 'lib/kthxbye/stats.rb', line 24 def incr( stat, by=1 ) redis.incrby("stat:#{stat}", by) end |
- (Object) reset(stat)
reset this stat to 0
34 35 36 |
# File 'lib/kthxbye/stats.rb', line 34 def reset( stat ) redis.del( "stat:#{stat}" ) end |