How can I set interval when repeating command several time in the interactive mode?
Like when I using redis-cli:
redis-cli -r 10 -i 1 PING
In interactive mode I can set amount of repeats before the command:
127.0.0.1:6379> 10 PING
But how can I set interval here?
You can start redis-cli with the -i interval option:
redis-cli -i 2
127.0.0.1:6379> 2 PING
However, in this case, all command will delay interval seconds, even if you don't want to repeat the command.
You may try
for i in {1..10}; do redis-cli ping ; echo "running for $i th time"; sleep $i; done;
Related
I am testing Redis (version: 0.8.8.384) using the benchmark tool, and the redis-server.exe that is included in the zip package locally.
I used the following command to test the keyspace_length:
redis-benchmark -t set,get -n 4 -c 1 -d 888 -r 1000
I have managed to capture a tracer (.pcap) locally using RawCap.exe.
What I have noticed is that the keys that are send in SET command, do not match with the keys in GET command. I would expect that the used keys are stored somewhere locally and then retrieved from the GET command to interrogate the value for each random key.
Am I missing something?
Thanks in advance!
It seems this behavior is the expected, since you can run a redis-benchmark for the GET command only:
redis-benchmark -t get -n 4 -c 1 -d 888 -r 1000
====== GET ======
4 requests completed in 0.00 seconds
1 parallel clients
888 bytes payload
keep alive: 1
100.00% <= 0 milliseconds
4000.00 requests per second
So each command specified in -t is tested independently.
Edit
You can pass a lua script to test a set/get in same key. Some thoughts after a post-lunch research :)
You can turn on MONITOR on redis-cli before executing this to be sure of what is happening. IMPORTANT: this will kill your benchmarking, just set it to see the actual commands using a small number of tests (e.g. redis-benchmark -n 10);
Since you're loading a lua script, this will be executed atomically every time, like if these command were in a MULTI/EXEC block;
You can lock a single random number to be used by both commands by specifying __rand_int__ parameter AND -r 1000 (e.g.). The -r parameter defines the range of random integers used. __rand_int__ WON'T work if you don't specify the -r parameter (you can see this when monitoring);
After turning MONITOR off, you can see that for bigger -n values the simulation seems to be faster. Try with -n 10 and -n 1000 and see if this holds true.
Read the https://redis.io/topics/benchmarks :)
The script:
redis-benchmark -r 10000 -n 1000 eval "redis.call('set',KEYS[1],'xpto') return redis.call('get', KEYS[1])" 1 __rand_int__
A sample MONITOR output:
1487868918.656881 [0 127.0.0.1:50561] "eval" "redis.call('set',KEYS[1],'xpto') return redis.call('get', KEYS[1])" "1" "000000009355"
1487868918.657032 [0 lua] "set" "000000009355" "xpto"
1487868918.657051 [0 lua] "get" "000000009355"
I'm trying to run some redis benchmark tests, but they're all giving the same error, unknown command redis-benchmark:
C:\>redis-cli
127.0.0.1:6379> redis-benchmark -t set,get -r 1000000 -q
(error) ERR unknown command 'redis-benchmark'
You cannot run the redis-benchmark command inside a redis-cli shell. It's not part of the redis-cli commands. Try a regular prompt instead:
Not working:
C:\>redis-cli
127.0.0.1:6379> redis-benchmark -t set,get -r 1000000 -q
Working:
C:\>redis-benchmark -t set,get -r 1000000 -q
Outputs something like:
SET: 111856.82 requests per second
GET: 108225.10 requests per second
redis-cli -s /data/redis/redis.sock --scan --pattern "*abcd|6128*" | xargs -L 100 redis-cli -s /data/redis/redis.sock DEL
above command is not deleting adta from redis and giving following output
(integer) 0
While the keys command works perfectly
redis-cli -s /data/redis/redis.sock KEYS 'abcd|6291*' | xargs redis-cli -s /data/redis/redis.sock DEL;
Is there is something wrong i am doing
Try xargs with -L 1 instead. Worked for me.
redis-cli -s /data/redis/redis.sock --scan --pattern "*abcd|6128*" | xargs -L 1 redis-cli -s /data/redis/redis.sock DEL
BTW, KEYS should be avoided in production environments as it is a blocking command.
scan only applies to some keys (by default on 10 keys per iteration). It returns an offset to continuesly run scan until you reach offset 0. Then you have sampled all keys. More details are in the documentation: http://redis.io/commands/scan
Keys on the other hand samples all keys in the db in one pass. It is also blocking due to redises single threaded architecture which might be bad for performance of other clients.
dThe following works as expected. But how do I insert the data into forth database instead of default "0" from command prompt?
# echo -n "testing" | /home/shantanu/redis-2.4.2/src/redis-cli -x set my_pass
OK
# echo -n "testing" | /home/shantanu/redis-2.4.2/src/redis-cli -x select 4; set my_pass
(error) ERR wrong number of arguments for 'select' command
Just use the -n argument to choose DB number. It available since Redis 2.4.2.
echo -n "testing" | redis-cli -n 4 -x set my_pass
or
redis-cli -n 4 set my_pass testing
Launch the CLI by issuing command:
redis-cli
Then use the following command:
select <db number>
For example:
select 4
When I pipe the echo to redis client, I get an error.
[root#server ~]$ echo "abc43345" | redis-cli set my_passwd2
(error) ERR wrong number of arguments for 'set' command
But the following works as expected.
[root#server ~]$ redis-cli set my_passwd2 `echo "abc43345"`
OK
Is there any way to make the first example work?
It can actually be achieved using "-x" flag
echo "abc43345" | redis-cli -x set my_passwd2