hedis
Safe HaskellNone
LanguageHaskell2010

Database.Redis.Connection

Synopsis

Documentation

data Connection Source #

A threadsafe pool of network connections to a Redis server. Use the connect function to create one.

data ConnectInfo Source #

Information for connnecting to a Redis server.

It is recommended to not use the ConnInfo data constructor directly. Instead use defaultConnectInfo and update it with record syntax. For example to connect to a password protected Redis server running on localhost and listening to the default port:

myConnectInfo :: ConnectInfo
myConnectInfo = defaultConnectInfo {connectAuth = Just "secret"}

Or better yet, use parseConnectInfo to parse a URL.

Constructors

ConnInfo 

Fields

Instances

Instances details
Show ConnectInfo Source # 
Instance details

Defined in Database.Redis.Connection

defaultConnectInfo :: ConnectInfo Source #

Default information for connecting:

 connectAddr           = ConnectAddrHostPort "localhost" 6379 -- Redis default port
 connectAuth           = Nothing         -- No password
 connectUsername       = Nothing         -- No user
 connectDatabase       = 0               -- SELECT database 0
 connectMaxConnections = 50              -- Up to 50 connections
 connectNumStripes     = Just 1          -- A single stripe
 connectMaxIdleTime    = 30              -- Keep open for 30 seconds
 connectTimeout        = Nothing         -- Don't add timeout logic
 connectTLSParams      = Nothing         -- Do not use TLS
 connectHooks          = defaultHooks    -- Do nothing
 connectPoolLabel      = ""              -- no label

connect :: ConnectInfo -> IO Connection Source #

Constructs a Connection pool to a Redis server designated by the given ConnectInfo.

The function always succeeds, because the first connection is not actually established until the first call to the server.

checkedConnect :: ConnectInfo -> IO Connection Source #

Constructs a Connection pool to a Redis server designated by the given ConnectInfo, then tests if the server is actually there.

Throws an ConnectError exception if the connection to the Redis server can't be established.

checkedConnectCluster :: ConnectInfo -> IO Connection Source #

Constructs a Connection pool to a Redis cluster designated by the given ConnectInfo, then tests if the server is actually there.

Throws an ClusterConnectError exception if the connection to the Redis server can't be established.

disconnect :: Connection -> IO () Source #

Destroy all idle resources in the pool, works for all types of the connection.

withConnect :: (MonadMask m, MonadIO m) => ConnectInfo -> (Connection -> m c) -> m c Source #

Memory bracket around connect and disconnect.

withCheckedConnect :: ConnectInfo -> (Connection -> IO c) -> IO c Source #

Memory bracket around checkedConnect and disconnect

runRedis :: Connection -> Redis a -> IO a Source #

Interact with a Redis datastore specified by the given Connection.

Each call of runRedis takes a network connection from the Connection pool and runs the given Redis action. Calls to runRedis may thus block while all connections from the pool are in use.

runRedisNonBlocking :: Connection -> Redis a -> IO (Maybe a) Source #

Interact with a Redis datastore specified by the given Connection, but return early if acquiring from the connection pool would block.

Like runRedis, but if all connections in the Connection pool are used, it immediately returns Nothing. This can be useful for logging purposes.

connectCluster :: ConnectInfo -> IO Connection Source #

Constructs a ShardMap of connections to clustered nodes. The argument is a ConnectInfo for any node in the cluster

Some Redis commands are currently not supported in cluster mode - CONFIG, AUTH - SCAN - MOVE, SELECT - RESET