sandfox / node-hapi-redis

A hapi plugin to provide redis
MIT License
9 stars 9 forks source link

Set not deleting... #18

Open scheung38 opened 7 years ago

scheung38 commented 7 years ago

After a set is added in create.js:

method: 'POST', 
path: '/', 
config: {
       validate: {
            payload: Joi.object().keys({
                event: Joi.string().required(),
                data: Joi.object().keys({
                    id: Joi.string().required()
                })
            }).required(),
        },
handler: (request, reply) => { 
    const redisClient = request.server.plugins['hapi-redis'].client; 
    redisClient.sadd('subscriptions', payload.data.id) }

but in another delete.js:

method: 'DELETE', 
path: '/{id}', 
config: {
        validate: {
            params: {
                id: Joi.string().required()
            }
        },
    },
handler: (request, reply) => { 
    const redisClient = request.server.plugins['hapi-redis'].client; 
    redisClient.srem('subscriptions', request.params.id }

Doesnt seem to delete? But delete.js seems to be reading from empty set?

But the corresponding redis-cli

sadd subscriptions id srem subscriptions id

work fine

sandfox commented 7 years ago

This is probably to do with the underlying Redis library. This module just exposes the redis library and doesn't modify it in any way. When I get near a computer I'll have a look, it could be that library ships with a very old version, or it could be a bug in the underlying library.

scheung38 commented 7 years ago

Can you replicate the same error in node