class Redis::Client

Overview

The Redis client is the expected entrypoint for this shard. By default, it will connect to localhost:6379, but you can also supply a URI to connect to an arbitrary Redis server. SSL, password authentication, and DB selection are all supported.

# Connects to localhost:6379
redis = Redis::Client.new

# Connects to a server at "redis.example.com" on port 6000 over a TLS
# connection, authenticates with the password "password", and uses DB 3
redis = Redis::Client.new(URI.parse("rediss://:[email protected]:6000/3"))

# Connects to a server at the URL in `ENV["REDIS_URL"]`
redis = Redis::Client.from_env("REDIS_URL")

Defined in:

client.cr
graph.cr

Constructors

Class Method Summary

Instance Method Summary

Macro Summary

Constructor Detail

def self.new(uri : URI = URI.parse(ENV.fetch("REDIS_URL", "redis:///"))) #

The client holds a pool of connections that expands and contracts as needed.


[View source]

Class Method Detail

def self.from_env(env_var) #

[View source]

Instance Method Detail

def graph(key : String) #

Instantiate a Redis::Graph::Client backed by this Redis::Client.


[View source]

Macro Detail

macro method_missing(call) #

All Redis commands invoked on the client check out a connection from the connection pool, invoke the command on that connection, and then check the connection back into the pool.

redis = Redis::Client.new

[View source]