class MiniRedis::Pool

Overview

A MiniRedis connection pool. It has dynamic #capacity and #block values.

Defined in:

mini_redis/pool.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(uri : URI = URI.parse("redis://localhost:6379"), capacity : Int32 = Int32::MAX, initial_size : Int32 = 0, logger : Logger? = nil, logger_severity : Logger::Severity = Logger::Severity::INFO, dns_timeout : Time::Span? = 5.seconds, connect_timeout : Time::Span? = 5.seconds, read_timeout : Time::Span? = nil, write_timeout : Time::Span? = 5.seconds) #

Initialize a new pool with #block initializing a MiniRedis client from the uri.


[View source]
def self.new(capacity : Int32 = Int32::MAX, initial_size : Int32 = 0, &block : -> MiniRedis) #

[View source]

Instance Method Detail

def block : Proc(MiniRedis) #

The pool's block to call to initialize a new MiniRedis instance. Can be changed after the pool is initialized.


[View source]
def block=(block : Proc(MiniRedis)) #

The pool's block to call to initialize a new MiniRedis instance. Can be changed after the pool is initialized.


[View source]
def capacity : Int32 #

The pool's capacity. Can be changed after the pool is initialized.


[View source]
def capacity=(capacity : Int32) #

The pool's capacity. Can be changed after the pool is initialized.


[View source]
def free #

The number of free clients in this pool.


[View source]
def get(timeout : Time::Span? = nil, &block : MiniRedis -> ) #

Yield a free MiniRedis client. Blocks until one is available, raises TimeoutError on optional timeout. Calls #release after yield.


[View source]
def get(timeout : Time::Span? = nil) : MiniRedis #

Return a free MiniRedis client. Blocks until one is available, raises TimeoutError on optional timeout.

NOTE Do not forget to #release the client afterwards!


[View source]
def release(redis : MiniRedis) : Nil #

Put the redis client back into the pool.


[View source]
def size #

The total size of this pool (#free plus #used).


[View source]
def used #

The number of clients in this pool currently being used.


[View source]