leanderlee/node-memstorage

Multi-Store Delete appears to delete more than specified

Closed this issue · 3 comments

When I try to delete from a multi store, it appears like it may be deleting more than what is specified in the key. Below is an example recreation:

    // Set and get a test path
    cache.cache['path'].set({ venue: "velocity-garage", origin: "test", destination: "test" }, { venue: "velocity-garage", origin: "test", destination: "test" }, function (result) {
        cache.cache['path'].get({ venue: "velocity-garage", origin: "test", destination: "test" }, function (result) {
            if (result.length > 0) {
                console.log("Path saved and retrieved successfully");
            } else {
                console.log("Path not retrieved or saved");
            }

            // Try deleting a path with different non-conflicting parameters
            cache.cache['path'].del({ venue: "velocity-garage", origin: "faux", destination: "test" }, function (result) {

                // Try to get original test path
                cache.cache['path'].get({ venue: "velocity-garage", origin: "test", destination: "test" }, function (result) {
                    if (result.length > 0) {
                        console.log("Path retrieved successfully again after irrelevant delete.");
                    } else {
                        console.log("Path not retrieved, the path must have been wrongfully deleted!");
                    }
                    res.send("Test Endpoint Called.");  
                });
            });
        });
    });

I can reproduce. Checking to see what the issue is.

Did you say there was another problem with setting?

Fixed and tests added,