Remove dynamic key/element from redis 6 in node.js

Viewed 38

I am trying to delete the key from redis upon successful download of the file requested from redis. The following function is intended to do that, but it is not working.

EDIT I just tried to use lrem instead of del, in case I am trying to remove an element - this did not work either

function delPub(key){
    if(key){
        return pubClient.del('redis-property', key);
    }
}
function delPub(key){
    if(key){
        return pubClient.del('redis-property', 1, key);// this does not seem to work either
    }
}

let pkg = ['shockatree.png'];

for(var o = 0; o < pkg.length; o++){
    delPub(pkg[o]);
}

Can someone please explain the proper way to delete a key? Or am I trying to delete an element instead?

Thank you!

2nd EDIT

the key I am trying to delete is actually a subkey, if that helps

1 Answers

My Solution: when you use pubClient.set(), use what ends up in pubDel(key) as the the key,like this:

return pubClient.del(key, 1, key);

I hope that makes sense to someone!

Related