How does one flush an entry from redis?

I've configured unbound to use redis as a backend.

I now have one erroneous entry cached in redis. I'm unable to flush that particular domain from the redis cache by doing:
`unbound-control flush domain.tld`. It only flushes unbound's in-memory cache.

When I `dig domain.tld` it keeps returning the incorrect cached IP.

What do?

Certainly NOT the best solution, but it works (emergencies)

My redis database contains only 1213 entries, so the processing time is acceptable.

I use a bash script (commented out the line that actually deletes the entry, dry run before you uncomment that line).

#!/bin/bash

mapfile -t keysArray < <(redis-cli --scan)

for (( i=0; i<${#keysArray[@]}; i++ )); do

data=$(echo “dump ${keysArray[i]}” | redis-cli | tr -d ‘\0’)

if [[ “${data}” == “accounts”“google”“com” ]]; then

echo “${keysArray[i]}”

redis-cli del “${keysArray[i]}”

fi

done

In order to look at the redis database, I use a web interface (https://packagist.org/packages/erik-dubbelboer/php-redis-admin)

My install script for this (into /var/www/html), using lighttpd

#!/bin/bash

sudo apt-get -y install libtool

sudo apt-get -y install php7.4-dev

sudo apt-get -y install php-redis

sudo apt-get -y install php-mbstring

cd /var/www/html

sudo git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git

cd phpRedisAdmin

sudo git clone https://github.com/nrk/predis.git vendor

Certainly NOT the best solution, but it works (emergencies)

My redis database contains only 1213 entries, so the processing time is
acceptable.

I use a bash script (commented out the line that actually deletes the
entry, dry run before you uncomment that line).

#!/bin/bash

mapfile -t keysArray < <(redis-cli --scan)
for (( i=0; i<${#keysArray[@]}; i++ )); do
   data=$(echo "dump ${keysArray[i]}" | redis-cli | tr -d '\0')
   if [[ "${data}" == *"accounts"*"google"*"com"* ]]; then
      echo "${keysArray[i]}"
      # redis-cli del "${keysArray[i]}"
   fi
done

Wow, when you say "bash script" there's no kidding, the above is
chock full of bash-specific extensions. My preference is for
portability, and not to force my own preferences on others, i.e.
using standards as much as possible.

As a non-redis user myself, I *think* the following shell script
should be equivalent to the above, and be portable to other
Bourne shells:

#!/bin/sh

redis-cli --scan | while read e; do
    data=$(echo "dump $e" | redis-cli | tr -d '\0')
    if expr "$data" : ".*accounts.*google.*com.*" > /dev/null;
    then
        echo "$e"
  # redis-cli del "$e"
    fi
done

Best regards,

- Havard