Created
September 19, 2012 02:07
-
-
Save krdlab/3747226 to your computer and use it in GitHub Desktop.
practice: Redis Pub/Sub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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