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'

Class Method Summary collapse

Class Method Details

.redis(&block) ⇒ Object

Raises:

  • (ArgumentError)

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

def redis(&block)
  raise ArgumentError, 'requires a block' unless block

  redis_pool.with(&block)
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