Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Add option to expire #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add option to expire #12

wants to merge 4 commits into from

Conversation

asupian
Copy link

@asupian asupian commented Nov 3, 2016

No description provided.

@colestrode
Copy link
Contributor

Thanks @asupian :) I think this is a good contribution

I noticed a few things that could use some cleaning up.

It looks like you are missing a closing brace for your if. Make sure to run npm test, that will catch your linting errors and any failing tests (we can't merge anything in until npm test runs clean).

If object.expire is not a parseable number, this will pass NaN to the redis client. I'm thinking it would be good to test that expire is a number in the if clause, something like

if (object.expire && !isNaN(parseInt(object.expire))) {
  client.EXPIRE(object.id, parseInt(object.expire))
}

Also would you mind adding a few tests that ensure thatclient.EXPIRE is set correctly and that bad values are handled correctly.

Thanks again!

@asupian
Copy link
Author

asupian commented Dec 8, 2016

Thanks for the note - apologies for the haste in submitting the pull request!

@asupian
Copy link
Author

asupian commented Jan 30, 2017

@colestrode feel free to review and merge this pull request!

@@ -34,6 +34,13 @@ module.exports = function(config) {
* @param {String} namespace The namespace to use for storing in Redis
* @returns {{get: get, save: save, all: all, allById: allById}}
*/
function isInt(n) {
if (isNaN(n) | n === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a double pipe operator for logical OR: ||

@colestrode
Copy link
Contributor

Sorry for the delay on getting back to you! I thought I had submitted the last comment, but got thwarted by the new Github review UI. I finally submitted that today.

If you're still interested in this feature, would you mind adding some tests to cover setting an expiration successfully and handling any errors that may occur (non-number, non-integer, and 0 are cases that come to mind)? Thanks and sorry again for the wait.

@asupian
Copy link
Author

asupian commented May 29, 2017

Sure, I'll add that shortly

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants