0

How can i find all elements in redis which is empty i have keys like this:

setting:1
setting:2
setting:442

etc

how can i search with redis-cli bash script command if any key contains empty value Something like redis-cli keys \* | xargs -L 1 redis-cli get with grep and check if value is empty

found solution

redis-cli KEYS "settings:*" | xargs -L 1 redis-cli get

1 Answer 1

1

The notion of an empty key in Redis is non-existent - there are no empty keys in Redis. If a key "becomes" empty (e.g. a List that was popped with the final element), the key does not exist in Redis anymore. Here's an example:

foo@bar:~$ redis-cli 
127.0.0.1:6379> exists foo
(integer) 0
127.0.0.1:6379> rpush foo bar
(integer) 1
127.0.0.1:6379> exists foo
(integer) 1
127.0.0.1:6379> lpop foo
"bar"
127.0.0.1:6379> exists foo
(integer) 0
127.0.0.1:6379> 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.