Skip to content

Instantly share code, notes, and snippets.

@krdlab
Created September 19, 2012 02:07
Show Gist options
  • Save krdlab/3747226 to your computer and use it in GitHub Desktop.
Save krdlab/3747226 to your computer and use it in GitHub Desktop.
practice: Redis Pub/Sub
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Database.Redis
import Control.Monad.IO.Class (liftIO)
main :: IO ()
main = do
conn <- connect defaultConnectInfo { connectHost = "xxx.xxx.xxx.xxx" }
runRedis conn $ do
res <- publish "test" "hogehoge"
liftIO . putStrLn $ show res
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Database.Redis
import Data.Monoid (mempty)
import qualified Data.ByteString.Char8 as BS
main :: IO ()
main = do
conn <- connect defaultConnectInfo { connectHost = "xxx.xxx.xxx.xxx" }
runRedis conn $ pubSub (subscribe ["test"]) $ \msg -> do
BS.putStrLn $ msgMessage msg
return mempty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment