redis bulk import using --pipe

后端 未结 6 1174
情深已故
情深已故 2020-12-30 11:56

I\'m trying to import one million lines of redis commands, using the --pipe feature.

redis_version:2.8.1

cat file.txt | r

6条回答
  •  有刺的猬
    2020-12-30 12:40

    To use the pipe mode (a.k.a mass insertion) you must indeed provide your commands directly in Redis protocol format.

    The corresponding Redis protocol for LPUSH name joe is:

    *3
    $5
    LPUSH
    $4
    name
    $3
    joe
    

    Or as a quoted string: "*3\r\n$5\r\nLPUSH\r\n$4\r\nname\r\n$3\r\njoe\r\n".

    This is what your input file must contain.

    The Redis documentation includes a Ruby sample to help you generate the protocol: see gen_redis_proto.

提交回复
热议问题