Hardbone
Hardbone

Reputation: 327

How to use random numbers when running redis-benchmark?

I used this but it doesn't work:

redis-benchmark -n 1000000 zadd ss ele:rand:000000000000 ele:rand:000000000000

After this,

zcard ss 

still returns 0 reuslt.

Why?

Many thanks.

Upvotes: 1

Views: 2488

Answers (1)

Didier Spezia
Didier Spezia

Reputation: 73306

There are two problems with this command line.

  • The second parameter of the zadd command must be a score (i.e. a number), not a key name. You cannot use ele:rand:000000000000 to represent a score. In your example, all the commands fail, that's why you have nothing in the zset in the end.

  • You are supposed to use the -r option to set the range for the random values of the keys

Example:

$ redis-benchmark -r 10000 -n 1000000 zadd ss 0 ele:rand:000000000000
$ redis-cli zcard ss
(integer) 10000

Upvotes: 2

Related Questions