informatikr / hedis

A Redis client library for Haskell.
http://hackage.haskell.org/package/hedis
BSD 3-Clause "New" or "Revised" License
327 stars 121 forks source link

slowlogGet 2 only return first slowlog entry #136

Closed Icarus0xff closed 5 years ago

Icarus0xff commented 5 years ago

I'm writing an application to get slowlogs from redis. But It prints only the first slowlog entry, I'm sure there are at least 3 slowlog entries and I could get them via slowlog get through redis-cli. Here is my code.

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Database.Redis
import Control.Monad.Trans

main :: IO ()
main = do
  conn <- connect defaultConnectInfo

  runRedis conn $ do
    logs <- slowlogGet 2

    liftIO $ print logs
    liftIO (print $ length logs)

Below is my program output:

Left (MultiBulk (Just [Integer 6,Integer 1557729655,Integer 1000808,MultiBulk (Just [Bulk (Just "debug"),Bulk (Just "sleep"),Bulk (Just "1")]),Bulk (Just "127.0.0.1:58270"),Bulk (Just "")]))
0

Below is my slowlog getoutput:

127.0.0.1:6379> SLOWLOG get
1) 1) (integer) 6
   2) (integer) 1557729655
   3) (integer) 1000808
   4) 1) "debug"
      2) "sleep"
      3) "1"
   5) "127.0.0.1:58270"
   6) ""
2) 1) (integer) 5
   2) (integer) 1557729654
   3) (integer) 1003804
   4) 1) "debug"
      2) "sleep"
      3) "1"
   5) "127.0.0.1:58270"
   6) ""
3) 1) (integer) 4
   2) (integer) 1557729652
   3) (integer) 1002081
   4) 1) "debug"
      2) "sleep"
      3) "1"
   5) "127.0.0.1:58270"
   6) ""
k-bx commented 5 years ago

Thanks for catching! The Left indicates that parsing failed. Since 4.0 redis added two fields we don't parse. Fixed, released under 0.12.5 version