Skip to content

Commit

Permalink
backend/enhancement: Implemented HMGET (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
dushyant-2002 authored Dec 18, 2024
1 parent f41d81d commit 42ddcc7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/mobility-core/src/Kernel/Storage/Hedis/Queries.hs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ hGet key field =
Nothing -> pure Nothing
Just bs -> Error.fromMaybeM (HedisDecodeError $ cs bs) $ Ae.decode $ BSL.fromStrict bs

hmGet :: (FromJSON a, HedisFlow m env) => Text -> [Text] -> m [Maybe a]
hmGet key fields =
withTimeRedis "RedisCluster" "hmGet" $ do
listBS <- runWithPrefix key (`Hedis.hmget` map cs fields)
mapM decodeBS listBS
where
decodeBS :: (FromJSON a, HedisFlow m env) => Maybe BS.ByteString -> m (Maybe a)
decodeBS Nothing = pure Nothing
decodeBS (Just bs) = Error.fromMaybeM (HedisDecodeError $ cs bs) $ Ae.decode $ BSL.fromStrict bs

hDel :: HedisFlow m env => Text -> [Text] -> m ()
hDel key fields = withTimeRedis "RedisCluster" "hDel" $ runWithPrefix_ key (`Hedis.hdel` map cs fields)

Expand Down

0 comments on commit 42ddcc7

Please sign in to comment.