hedis 0.12.15 → 0.13.0
raw patch · 5 files changed
+66/−61 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Database.Redis: hset :: RedisCtx m f => ByteString -> ByteString -> ByteString -> m (f Bool)
+ Database.Redis: hset :: RedisCtx m f => ByteString -> ByteString -> ByteString -> m (f Integer)
- Database.Redis.Sentinel: hset :: RedisCtx m f => ByteString -> ByteString -> ByteString -> m (f Bool)
+ Database.Redis.Sentinel: hset :: RedisCtx m f => ByteString -> ByteString -> ByteString -> m (f Integer)
Files
- CHANGELOG +4/−0
- hedis.cabal +1/−1
- src/Database/Redis/Commands.hs +1/−1
- test/PubSubTest.hs +55/−56
- test/Test.hs +5/−3
CHANGELOG view
@@ -1,5 +1,9 @@ # Changelog for Hedis +## 0.13.0++* PR #159. Issue #152. Make HSET return integer instead of bool+ ## 0.12.15 * PR #154. Implement Redis Sentinel support
hedis.cabal view
@@ -1,5 +1,5 @@ name: hedis-version: 0.12.15+version: 0.13.0 synopsis: Client library for the Redis datastore: supports full command set, pipelining.
src/Database/Redis/Commands.hs view
@@ -830,7 +830,7 @@ => ByteString -- ^ key -> ByteString -- ^ field -> ByteString -- ^ value- -> m (f Bool)+ -> m (f Integer) hset key field value = sendRequest (["HSET"] ++ [encode key] ++ [encode field] ++ [encode value] ) brpoplpush
test/PubSubTest.hs view
@@ -70,35 +70,34 @@ ctrl <- newPubSubController [("foo1", handler "InitialFoo1" msgVar), ("foo2", handler "InitialFoo2" msgVar)] [("bar1:*", phandler "InitialBar1" msgVar), ("bar2:*", phandler "InitialBar2" msgVar)] withAsync (pubSubForever conn ctrl (atomically $ writeTVar initialComplete True)) $ \_ -> do-- -- wait for initial- atomically $ readTVar initialComplete >>= \b -> if b then return () else retry- expectRedisChannels conn ["foo1", "foo2"]+ -- wait for initial+ atomically $ readTVar initialComplete >>= \b -> if b then return () else retry+ expectRedisChannels conn ["foo1", "foo2"] - runRedis conn $ publish "foo1" "Hello"- waitForMessage msgVar "InitialFoo1" "Hello"+ runRedis conn $ publish "foo1" "Hello"+ waitForMessage msgVar "InitialFoo1" "Hello" - runRedis conn $ publish "bar2:zzz" "World"- waitForPMessage msgVar "InitialBar2" "bar2:zzz" "World"+ runRedis conn $ publish "bar2:zzz" "World"+ waitForPMessage msgVar "InitialBar2" "bar2:zzz" "World" - -- subscribe to foo1 and bar1 again- addChannelsAndWait ctrl [("foo1", handler "NewFoo1" msgVar)] [("bar1:*", phandler "NewBar1" msgVar)]- expectRedisChannels conn ["foo1", "foo2"]+ -- subscribe to foo1 and bar1 again+ addChannelsAndWait ctrl [("foo1", handler "NewFoo1" msgVar)] [("bar1:*", phandler "NewBar1" msgVar)]+ expectRedisChannels conn ["foo1", "foo2"] - runRedis conn $ publish "foo1" "abcdef"- waitForMessage msgVar "InitialFoo1" "abcdef"- waitForMessage msgVar "NewFoo1" "abcdef"+ runRedis conn $ publish "foo1" "abcdef"+ waitForMessage msgVar "InitialFoo1" "abcdef"+ waitForMessage msgVar "NewFoo1" "abcdef" - -- unsubscribe from foo1 and bar1- removeChannelsAndWait ctrl ["foo1", "unusued"] ["bar1:*", "unused:*"]- expectRedisChannels conn ["foo2"]+ -- unsubscribe from foo1 and bar1+ removeChannelsAndWait ctrl ["foo1", "unusued"] ["bar1:*", "unused:*"]+ expectRedisChannels conn ["foo2"] - -- foo2 and bar2 are still subscribed- runRedis conn $ publish "foo2" "12345"- waitForMessage msgVar "InitialFoo2" "12345"+ -- foo2 and bar2 are still subscribed+ runRedis conn $ publish "foo2" "12345"+ waitForMessage msgVar "InitialFoo2" "12345" - runRedis conn $ publish "bar2:aaa" "0987"- waitForPMessage msgVar "InitialBar2" "bar2:aaa" "0987"+ runRedis conn $ publish "bar2:aaa" "0987"+ waitForPMessage msgVar "InitialBar2" "bar2:aaa" "0987" data TestError = TestError ByteString deriving (Eq, Show, Typeable)@@ -127,48 +126,48 @@ initialComplete <- newTVarIO False ctrl <- newPubSubController [] [] withAsync (pubSubForever conn ctrl (atomically $ writeTVar initialComplete True)) $ \_ -> do- atomically $ readTVar initialComplete >>= \b -> if b then return () else retry+ atomically $ readTVar initialComplete >>= \b -> if b then return () else retry - -- register to some channels- void $ addChannelsAndWait ctrl- [("abc", handler "InitialAbc" msgVar), ("xyz", handler "InitialXyz" msgVar)]- [("def:*", phandler "InitialDef" msgVar), ("uvw", phandler "InitialUvw" msgVar)]- expectRedisChannels conn ["abc", "xyz"]+ -- register to some channels+ void $ addChannelsAndWait ctrl+ [("abc", handler "InitialAbc" msgVar), ("xyz", handler "InitialXyz" msgVar)]+ [("def:*", phandler "InitialDef" msgVar), ("uvw", phandler "InitialUvw" msgVar)]+ expectRedisChannels conn ["abc", "xyz"] - runRedis conn $ publish "abc" "Hello"- waitForMessage msgVar "InitialAbc" "Hello"+ runRedis conn $ publish "abc" "Hello"+ waitForMessage msgVar "InitialAbc" "Hello" - -- register to some more channels- unreg <- addChannelsAndWait ctrl- [("abc", handler "SecondAbc" msgVar), ("123", handler "Second123" msgVar)]- [("def:*", phandler "SecondDef" msgVar), ("890:*", phandler "Second890" msgVar)]- expectRedisChannels conn ["abc", "xyz", "123"]+ -- register to some more channels+ unreg <- addChannelsAndWait ctrl+ [("abc", handler "SecondAbc" msgVar), ("123", handler "Second123" msgVar)]+ [("def:*", phandler "SecondDef" msgVar), ("890:*", phandler "Second890" msgVar)]+ expectRedisChannels conn ["abc", "xyz", "123"] - -- check messages on all channels- runRedis conn $ publish "abc" "World"- waitForMessage msgVar "InitialAbc" "World"- waitForMessage msgVar "SecondAbc" "World"+ -- check messages on all channels+ runRedis conn $ publish "abc" "World"+ waitForMessage msgVar "InitialAbc" "World"+ waitForMessage msgVar "SecondAbc" "World" - runRedis conn $ publish "123" "World2"- waitForMessage msgVar "Second123" "World2"+ runRedis conn $ publish "123" "World2"+ waitForMessage msgVar "Second123" "World2" - runRedis conn $ publish "def:bbbb" "World3"- waitForPMessage msgVar "InitialDef" "def:bbbb" "World3"- waitForPMessage msgVar "SecondDef" "def:bbbb" "World3"+ runRedis conn $ publish "def:bbbb" "World3"+ waitForPMessage msgVar "InitialDef" "def:bbbb" "World3"+ waitForPMessage msgVar "SecondDef" "def:bbbb" "World3" - runRedis conn $ publish "890:tttt" "World4"- waitForPMessage msgVar "Second890" "890:tttt" "World4"+ runRedis conn $ publish "890:tttt" "World4"+ waitForPMessage msgVar "Second890" "890:tttt" "World4" - -- unregister- unreg+ -- unregister+ unreg - -- we have no way of waiting until unregister actually happened, so just delay and hope- threadDelay $ 1000*1000 -- 1 second- expectRedisChannels conn ["abc", "xyz"]+ -- we have no way of waiting until unregister actually happened, so just delay and hope+ threadDelay $ 1000*1000 -- 1 second+ expectRedisChannels conn ["abc", "xyz"] - -- now only initial should be around. In particular, abc should still be subscribed- runRedis conn $ publish "abc" "World5"- waitForMessage msgVar "InitialAbc" "World5"+ -- now only initial should be around. In particular, abc should still be subscribed+ runRedis conn $ publish "abc" "World5"+ waitForMessage msgVar "InitialAbc" "World5" - runRedis conn $ publish "def:cccc" "World6"- waitForPMessage msgVar "InitialDef" "def:cccc" "World6"+ runRedis conn $ publish "def:cccc" "World6"+ waitForPMessage msgVar "InitialDef" "def:cccc" "World6"
test/Test.hs view
@@ -196,7 +196,7 @@ del ["key"] >>=? 1 where ts = [ (set "key" "value" >>=? Ok, String)- , (hset "key" "field" "value" >>=? True, Hash)+ , (hset "key" "field" "value" >>=? 1, Hash) , (lpush "key" ["value"] >>=? 1, List) , (sadd "key" ["member"] >>=? 1, Set) , (zadd "key" [(42,"member"),(12.3,"value")] >>=? 2, ZSet)@@ -255,7 +255,9 @@ -- testHashes :: Test testHashes = testCase "hashes" $ do- hset "key" "field" "value" >>=? True+ hset "key" "field" "another" >>=? 1+ hset "key" "field" "another" >>=? 0+ hset "key" "field" "value" >>=? 0 hsetnx "key" "field" "value" >>=? False hexists "key" "field" >>=? True hlen "key" >>=? 1@@ -634,7 +636,7 @@ scanOpts cursor0 sOpts2 >>=? (cursor0, []) sadd "set" ["1"] >>=? 1 sscan "set" cursor0 >>=? (cursor0, ["1"])- hset "hash" "k" "v" >>=? True+ hset "hash" "k" "v" >>=? 1 hscan "hash" cursor0 >>=? (cursor0, [("k", "v")]) zadd "zset" [(42, "2")] >>=? 1 zscan "zset" cursor0 >>=? (cursor0, [("2", 42)])