Spring data redis uses the Luttuce client to delete the specified key question

1, background

official Redis cluster clustering scheme currently used by redis:

spring data redis and Luttuce currently used by cli: (luttuce is better than jedis instead of jedis, cluster)

2. Purpose
want to delete some pattern matching key

online because of blocking high-risk commands such as keys, flushdb

so currently use scan to match key and delete them one by one, but when it is actually executed, the exception is reported as follows:

InvalidDataAccessApiUsageException: Scan is not supported across multiple nodes within a cluster

to flip the source code, it is true that cluster does not support direct scan cluster, to ask how to implement it?

when redis is in master-slave mode, it is written like this:

public void flushdb() {
        ScanOptions scanOptions = new ScanOptions.ScanOptionsBuilder().match("user_slash*").count(1000).build();
        redisTemplate.execute((RedisCallback<Object>) connection -> {
            Cursor<byte[]> cursor = connection.scan(scanOptions);
            while (cursor.hasNext()) {
                connection.del(cursor.next());
            }
            return null;
        });
    }
Issues not found on

spring data redis github


get all nodes and use the scan command to read them respectively;
cursor remember that close (), will not release the connection if you finish using it.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b321c7-2be04.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b321c7-2be04.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?