packages feed

redis 0.8.1 → 0.9

raw patch · 3 files changed

+26/−17 lines, 3 files

Files

Database/Redis/Internal.hs view
@@ -5,7 +5,6 @@ import Control.Concurrent (ThreadId, myThreadId) import Control.Concurrent.MVar import Data.IORef-import qualified Network.Socket as S import qualified System.IO as IO import System.IO.UTF8 (putStrLn, putStr) import qualified Data.ByteString as B
Database/Redis/Redis.hs view
@@ -204,11 +204,9 @@ -- | Conects to Redis server and returns connection descriptor connect :: String -> String -> IO Redis connect hostname port =-    do serveraddr <- head `fmap` S.getAddrInfo Nothing (Just hostname) (Just port)--       s <- S.socket (S.addrFamily serveraddr) S.Stream S.defaultProtocol-       S.setSocketOption s S.KeepAlive 1-       S.connect s (S.addrAddress serveraddr)+    do s <- if null port+              then socket_unix hostname+              else socket_inet hostname port         h <- S.socketToHandle s IO.ReadWriteMode        IO.hSetBuffering h (IO.BlockBuffering Nothing)@@ -218,6 +216,22 @@        st <- newIORef $ RedisState (hostname, port) 0 h 0        return $ Redis lcnt l st +socket_inet :: String -> String -> IO S.Socket+socket_inet hostname port =+    do serveraddr <- head `fmap` S.getAddrInfo Nothing (Just hostname) (Just port)++       s <- S.socket (S.addrFamily serveraddr) S.Stream S.defaultProtocol+       S.setSocketOption s S.KeepAlive 1+       S.connect s (S.addrAddress serveraddr)+       return s++socket_unix :: String -> IO S.Socket+socket_unix path =+    do s <- S.socket S.AF_UNIX S.Stream S.defaultProtocol+       S.setSocketOption s S.KeepAlive 0+       S.connect s (S.SockAddrUnix path)+       return s+ -- | Close connection disconnect :: Redis -> IO () disconnect = withState' (IO.hClose . handle)@@ -627,7 +641,7 @@ -- RBulk returned substr :: (BS s1, BS s2) =>           Redis-       -> s1                    -- ^ traget key+       -> s1                    -- ^ target key        -> (Int, Int)            -- ^ (start, end)        -> IO (Reply s2) substr r key (from, to) = withState r (\rs -> sendCommand rs (CMBulk ["SUBSTR", toBS key, toBS from, toBS to]) >> recv rs)@@ -685,7 +699,7 @@ -- RMulti filled with RBulk returned lrange :: (BS s1, BS s2) =>           Redis-       -> s1                    -- ^ traget key+       -> s1                    -- ^ target key        -> (Int, Int)            -- ^ (from, to) pair        -> IO (Reply s2) lrange r key (from, to) = withState r (\rs -> sendCommand rs (CMBulk ["LRANGE", toBS key, toBS from, toBS to]) >> recv rs)
redis.cabal view
@@ -1,5 +1,5 @@ Name:                redis-Version:             0.8.1+Version:             0.9 License:             MIT Maintainer:          Alexander Bogdanov <andorn@gmail.com> Author:              Alexander Bogdanov <andorn@gmail.com>@@ -16,15 +16,11 @@ 	protocol. Most of the functions will work correctly with stable version 	but not all. 	.-	Changes from v0.7:-	.-	- new commands added: strlen, persist-	.-	- zrangebyscore now supports LIMIT argument. Warning! Backward incompatible change!-	.-	- fixed behaviour of sort with multiple GET keys+	Changes from v0.8: 	.-	- exceptions handled in run_multi and run_cas blocks leads to abort transaction explicitly+	- Now it's able to connect Redis using unix sockets. To do so just+	call /connect/ with path to socket as first argument and empty+	second argument. 	.  Stability:           beta