Class: Counter
- Inherits:
-
RedisConnection
- Object
- RedisConnection
- Counter
- Defined in:
- lib/redis_store.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Attributes inherited from RedisConnection
Instance Method Summary collapse
- #del ⇒ Object
- #incr ⇒ Object
-
#initialize(key) ⇒ Counter
constructor
A new instance of Counter.
- #to_s ⇒ Object
Methods inherited from RedisConnection
Constructor Details
#initialize(key) ⇒ Counter
Returns a new instance of Counter.
90 91 92 93 |
# File 'lib/redis_store.rb', line 90 def initialize key @key = key super end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
88 89 90 |
# File 'lib/redis_store.rb', line 88 def key @key end |
Instance Method Details
#del ⇒ Object
99 100 101 |
# File 'lib/redis_store.rb', line 99 def del @redis.hdel "counters", @key end |
#incr ⇒ Object
95 96 97 |
# File 'lib/redis_store.rb', line 95 def incr @redis.hincrby "counters", @key, 1 end |
#to_s ⇒ Object
103 104 105 |
# File 'lib/redis_store.rb', line 103 def to_s @redis.hget "counters", @key end |