Module: Rollie

Defined in:
lib/rollie.rb,
lib/rollie/status.rb,
lib/rollie/version.rb,
lib/rollie/redis_pool.rb,
lib/rollie/rate_limiter.rb

Defined Under Namespace

Classes: RateLimiter, RedisPool, Status

Constant Summary collapse

VERSION =
"0.1.1".freeze

Class Method Summary collapse

Class Method Details

.redisObject

Raises:

  • (ArgumentError)


9
10
11
12
13
14
# File 'lib/rollie.rb', line 9

def redis
  raise ArgumentError, "requires a block" unless block_given?
  redis_pool.with do |conn|
    yield(conn)
  end
end

.redis=(options) ⇒ Object

Configures the redis connection pool. Options can be a hash of redis connection pool options or a pre-configured ConnectionPool instance.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :url (String)

    The redis connection URL

  • :driver (String)

    The redis driver

  • :pool_size (Integer)

    Size of the connection pool

  • :pool_timeout (Integer)

    Pool timeout in seconds

  • :namespace (String)

    Optional namespace for redis keys



24
25
26
27
28
29
30
# File 'lib/rollie.rb', line 24

def redis=(options)
  @redis_pool = if options.is_a?(ConnectionPool)
    options
   else
    Rollie::RedisPool.create(options)
   end
end

.redis_poolObject



32
33
34
# File 'lib/rollie.rb', line 32

def redis_pool
  @redis_pool ||= Rollie::RedisPool.create
end