I want know how we can delete all keys for a specific namespace only?
FLUSHALL
delete all keys, its a problem when using multiple app with same redis server.
I want know how we can delete all keys for a specific namespace only?
FLUSHALL
delete all keys, its a problem when using multiple app with same redis server.
you can not flush a namespace in Redis, while you can flush all keys matching a pattern.
$ redis-cli --scan --pattern 'user:*' | xargs redis-cli unlink
You should use (always with caution) FLUSHDB after ensuring you had SELECTed the right database.
On a related subject, you should consider using shared databases really carefully - there are all sorts of nastiness that can ensue from as well as the fact that it isn't compatible with the upcoming Redis cluster (v3 that is in beta, expected release EOY). You may want to look at this benchmark post about Shared vs. Dedicated Redis instances for more background on the subject.
flush(namespace){
console.log('delete namespace: ', namespace);
redis.defineCommand('flush', {
numberOfKeys: 0,
lua: 'local keys = redis.call(\'keys\', ARGV[1]) for i=1,#keys,5000 do ' +
'redis.call(\'del\', unpack(keys, i, math.min(i+4999, #keys))) end return keys'
});
}