diff --git a/lib/index.js b/lib/index.js index 27ff89b..3ceb6a4 100755 --- a/lib/index.js +++ b/lib/index.js @@ -140,9 +140,7 @@ internals.Connection.prototype.get = async function (key) { throw Error('Bad envelope content'); } - if ((!envelope.item && envelope.item !== 0) || - !envelope.stored) { - + if (!envelope.stored || !envelope.hasOwnProperty('item')) { throw Error('Incorrect envelope structure'); } diff --git a/test/index.js b/test/index.js index c5574c9..f09f057 100755 --- a/test/index.js +++ b/test/index.js @@ -787,6 +787,25 @@ describe('Redis', () => { const result = await redis.get(key); expect(result.item).to.equal(0); }); + + it('can store and retrieve falsy values such as boolean false', async () => { + + const options = { + host: '127.0.0.1', + port: 6379, + partition: 'wwwtest' + }; + const key = { + id: 'test', + segment: 'test' + }; + + const redis = new Redis(options); + await redis.start(); + await redis.set(key, false, 200); + const result = await redis.get(key); + expect(result.item).to.equal(false); + }); }); describe('set()', () => {