\# redis-server -v
Redis server v=3.0.5 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=efd64775fb9b8d51
\# redis-cli -v
redis-cli 3.0.5
\# redis-cli
127.0.0.1:6379> set foo 10 10
(error) ERR syntax error
http://redis.io/commands/set
SET key value [EX seconds] [PX milliseconds] [NX|XX] Starting with
Redis 2.6.12 SET supports a set of options that modify its behavior:
why ?
# redis-cli
127.0.0.1:6379> set foo 10 ex 10
OK
very impressed
Related
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;
I am trying to delete some keys but cannot execute any redis-cli commands:
redis-cli --scan --patter 'assetInfo*' | xargs redis-cli del
The error is:
(error) ERR unknown command: redis-cli
I am using REDIS version 3.2.7. Does this version not support redis-cli?
What gives?
Update: When I do this without 'redis-cli' I get this:
Azure Redis Health Dev:0>--scan --pattern 'spout*' | xargs redis-cli del
ERR unknown command: --scan
The error you're getting is a Redis error, which means you're already connected (and probably inside the cli). redis-cli is a command line (i.e. shell) utility for opening a connection to Redis and running commands.
P.S. your --pattern switch is missing an "n"
I just installed Redis 3.0.4 on Ubuntu Server 11.04.3 LTS
I'm running redis-cli but when I type
127.0.0.1:6379> set myKey hello
or
127.0.0.1:6379> set myKey 'hello'
or
127.0.0.1:6379> set myKey "hello"
it displays
(error) ERR unknown command 'set'
if I type
127.0.0.1:6379> help set
it displays
SET key value [EX seconds] [PX milliseconds] [NX|XX]
summary: Set the string value of a key
since: 1.0.0
group: string
I leave here the info that Redis gave me for more help
127.0.0.1:6379> info
# Server
redis_version:3.0.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:ca8b1c102698f8cb
redis_mode:sentinel
os:Linux 3.19.0-25-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.4
process_id:1196
run_id:28b1360b9c9c17d2c4645a0b541a080c6c35a263
tcp_port:6379
uptime_in_seconds:3212
uptime_in_days:0
hz:18
lru_clock:1675551
config_file:/etc/redis.conf
thanks for any help
You probably ran as redis-sentinal <...redis.conf> but your redis master is not running or unavailable or was never configured. sentinal is a failover mechanism and mostly runs on different node than master.
If you want to run the redis server in standalone mode you can just run this
redis-server < path to redis.conf>. This will let you connect and get going.
I found a solution to the problem
at the config file redis.conf I put a valid path to the directive "dir" under SNAPSHOTTING
dir /some/valid/path/
also have to change the default value of 128 on /proc/sys/net/core/somaxconn to 511
and just restart the service and it worked
In my case the redis.conf file had
############################### Disable some dangerous commands ##############
rename-command CONFIG ""
by commenting that line and restarted redis solved it
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