Safe Haskell | None |
---|
Redis DB snaplet.
- data RedisDB
- runRedisDB :: (MonadIO m, MonadState app m) => Simple Lens app (Snaplet RedisDB) -> Redis a -> m a
- redisConnection :: Simple Lens RedisDB Connection
- redisDBInit :: ConnectInfo -> SnapletInit b RedisDB
- redisDBInitConf :: SnapletInit b RedisDB
Documentation
runRedisDB :: (MonadIO m, MonadState app m) => Simple Lens app (Snaplet RedisDB) -> Redis a -> m aSource
Perform action using Redis connection from RedisDB snaplet pool
(wrapper for runRedis
).
runRedisDB database $ do set "hello" "world"
redisConnection :: Simple Lens RedisDB ConnectionSource
A lens to retrieve the connection to Redis from the RedisDB
wrapper.
:: ConnectInfo | Information for connnecting to a Redis server. |
-> SnapletInit b RedisDB |
Make RedisDB snaplet and initialize database connection.
appInit :: SnapletInit MyApp MyApp appInit = makeSnaplet "app" "App with Redis child snaplet" Nothing $ do d <- nestSnaplet "" database $ redisDBInit defaultConnectInfo return $ MyApp d
redisDBInitConf :: SnapletInit b RedisDBSource
Make RedisDB snaplet and initialize database connection from snaplet config file. Options are read from the redis section of the application config (e.g. ./devel.cfg) or from the main section of the Redis snaplet config (e.g. .snapletsredis/devel.cfg).
Every field is optional and defaults to defaultConnectInfo values.
redis { host = "192.168.0.42" port = 31415 auth = "i am so secret" max_connections = 1 max_idle_time = 0.5 }
appInit :: SnapletInit MyApp MyApp appInit = makeSnaplet "app" "App with Redis child snaplet" Nothing $ do d <- nestSnaplet "redis" database redisDBInitConf return $ MyApp d