I'm trying to figure out how to clear a bunch of keys in redis from the cache in the most efficient manner possible.
In this example I'm getting a string array of userIds. Each user has a watchlist of auctionIds in their user document inside mongodb
"watchlist": [
    "5eb81dbaecb87a4060c3d5a7",
    "5eb81e24ecb87a4060c3d5a8",
    "5eb8302ebae779466c97c1d9"
  ],
It's an auction site so if a user places a bid, then I need the watchlists that have the listing inside that user's [string] watchlist to clear the cache for that key const watchlistKey = `watchlist-${req.query.userIdBidder}`;
but in production that could be 100s of ids. Who knows. I've been using this library for other pattern delete examples: https://www.npmjs.com/package/redis-delete-wildcard?activeTab=readme but I don't think I can apply it to this use case. What will be the most cost effective way to clear the cache using string array as input data?
  User.find({
        watchlist: { $in: [req.query.listingId] },
      }).select("_id").then((res) => {
        console.log(res);
        const watchlistKey = `watchlist-${req.query.userIdBidder}`;
        client.delwild('main-listings-no-filter-page=*', function (error, numberDeletedKeys) {
          console.log("Page Didn't Match During Bid. All Listings Pages have been removed from cache.");
          console.log(numberDeletedKeys);
        });
      })
Console Output
 [ { _id: 5eb8196eecb87a4060c3d5a5 },
  { _id: 5eb82d0c71b0a230b853bd6f } ]