stax
stax

Reputation: 93

Redis - Is there a limit on SET for datatype STRING?

I am using the command line interface on my mac terminal to set a long string.

SET mystring "[long string]"

Now the issue is this. When i copy from my text editor the long string into the cli, the pasted string gets cut off at 4,066 characters.

I thought it could be the copy/paste buffer size of the mac terminal but i can paste stings alot longer outside of redis-cli.

And its no where near the 512 Megabytes limit for a STRING in redis.

This is similar to another questions but not the same steps. Redis cuts of the string when getting a serialized object back. Cant find any limits

thanks!

Upvotes: 9

Views: 4184

Answers (3)

tetafro
tetafro

Reputation: 546

You can use -x option to read value from stdin

redis-cli -x -h localhost -p 6379 set my-key < /path/to/file.txt

Upvotes: 5

Vikash
Vikash

Reputation: 2163

A simpler way to use APPEND command. Though some effort is required to break the long string. That can be done using notepad++ see this.

127.0.0.1:6379> set greet hello
OK
127.0.0.1:6379> APPEND greet " world"
(integer) 11
127.0.0.1:6379> get greet
"hello world"

Upvotes: 1

rkhayrov
rkhayrov

Reputation: 10260

redis-cli uses linenoise custom library for terminal input, which happens to have hard-coded input buffer size of 4096 bytes: linenoise.c:101. You may want to write down your Redis command into a file and execute it with redis-cli --eval.

Upvotes: 7

Related Questions