wai-middleware-caching-redis- Cache Wai Middleware using Redis backend

Safe HaskellNone




cache :: RedisCacheBackend -> Middleware Source

cacheNoBody :: RedisCacheBackend -> Middleware Source

newCacheBackend :: ConnectInfo -> (Request -> ByteString -> IO Bool) -> (Request -> Response -> IO ()) -> (Request -> Response -> IO ()) -> IO RedisCacheBackend Source

defaultCacheBackend :: IO RedisCacheBackend Source

Cache Backend which cache all GET requests using local redis on standard port You should use cacheNoBody instead of cache

defaultConnectInfo :: ConnectInfo

Default information for connecting:

 connectHost           = "localhost"
 connectPort           = PortNumber 6379 -- Redis default port
 connectAuth           = Nothing         -- No password
 connectDatabase       = 0               -- SELECT database 0
 connectMaxConnections = 50              -- Up to 50 connections
 connectMaxIdleTime    = 30              -- Keep open for 30 seconds

data ConnectInfo :: *

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"}




connectHost :: HostName
connectPort :: PortID
connectAuth :: Maybe ByteString

When the server is protected by a password, set connectAuth to Just the password. Each connection will then authenticate by the auth command.

connectDatabase :: Integer

Each connection will select the database with the given index.

connectMaxConnections :: Int

Maximum number of connections to keep open. The smallest acceptable value is 1.

connectMaxIdleTime :: NominalDiffTime

Amount of time for which an unused connection is kept open. The smallest acceptable value is 0.5 seconds. If the timeout value in your redis.conf file is non-zero, it should be larger than connectMaxIdleTime.