Method: Redis::Counter#initialize

Defined in:
lib/redis/counter.rb

#initialize(key, redis = $redis, options = {}) ⇒ Counter

Returns a new instance of Counter.



14
15
16
17
18
19
20
# File 'lib/redis/counter.rb', line 14

def initialize(key, redis=$redis, options={})
  @key = key
  @redis = redis
  @options = options
  @options[:start] ||= 0
  @redis.setnx(key, @options[:start]) unless @options[:start] == 0 || @options[:init] === false
end