I am facing issue while trying to use the UNLINK command with redis. Version that I am using is 5.0.8.
Any work around with this?
root#test:/tmp/redis-stable# redis-cli --version
redis-cli 5.0.8
root#test:/tmp/redis-stable# redis-cli
127.0.0.1:6379> keys
(error) ERR wrong number of arguments for 'keys' command
127.0.0.1:6379> keys *
1) "51"
2) "key2"
3) "key1"
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> UNLINK key1
(error) ERR unknown command 'UNLINK'
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> UNLINK key1 key2
(error) ERR unknown command 'UNLINK'
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
Is this a known issue or any version specific version..
Regards,
Vicky
Thanks #ItamarHaber,
I did had an upgraded version of 5.0.8 running but seems the old version was being picked up.
On doing a SHUTDOWN from redis-cli and again starting the redis-server, resolved the issue.
Related
In my MacOs 10.15 environment I have a strange Redis behaviour when I list some keys with:
redis-cli -n 1 --scan --pattern "product_doctrine*"
It gives me for example:
product_doctrine[AppBundle\Entity\ColumnMapping\$GEDMO_TIMESTAMPABLE_CLASSMETADATA][21546]
But It doesn’t delete it using xargs:
redis-cli -n 1 --scan --pattern "product_doctrine*" | xargs -L 1 redis-cli -n 1 del
(integer) 0
Is it maybe of the key name having special characters? Because if I run this inide the redis-cli:
SCAN 0 MATCH product_doctrine*
it shows the keys with escaped antislash:
"product_doctrine[AppBundle\\Entity\\ShopSettings\\$GEDMO_SOFTDELETEABLE_CLASSMETADATA][11677]"
Inside redis-cli I can delete those kind of keys successfully with
127.0.0.1:6379[1]> del "product_doctrine[AppBundle\\Entity\\ShopSettings\\$GEDMO_SOFTDELETEABLE_CLASSMETADATA][11677]"
(integer) 1
On macOS 10.14 the following does it:
redis-cli --scan --pattern "foo*" | sed 's/\\/\\\\/' | xargs -L 1 redis-cli DEL
¯\_(ツ)_/¯
I want get value by redis-cli keys
This is work
redis-cli keys number_* | xargs redis-cli del
But this is not work
redis-cli keys number_* | xargs redis-cli get
The difference between DEL and GET, in this context, is that the former is variadic (i.e. accepts one or more arguments) whereas the latter isn't (one and only one key name is expected).
To solve this you can choose one of the following:
Use the -L switch with xargs, i.e.: redis-cli keys number_* | xargs -L 1 redis-cli get
Use MGET, i.e.: redis-cli keys number_* | xargs redis-cli mget
Important warning: KEYS is a dangerous command as it may block the server for a long time - do not use it in production!
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"
\# 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
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