-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Success when there is no cache objects #11
Comments
That's because when there is no hit on the cache, it doesn't return an error but an empty object as second parameter. Use something like |
I'll throw my hat in the ring here and argue that it should at least return returning |
Have to say was thrown by the same issue as well. |
Returning a truthy value on miss seems very strange. Any rationale behind this? |
@mpneuried can we please get a comment on this? |
As i recall the reason for this behaviour is that GET and MGET can be used in the same way. If it was just for the GET you could return just the value, but with MGET where you supply n keys you need to return those keys (if found) in the object. |
Hi there, as my colleague @smrchy explained the answer format of the So my proposal is to change the behaviour of the Would this be a solution? |
I implemented the solution within the v2 branch. |
Could you just return if(!mycache.get('foo')) { ... } |
meanwhile
|
Also I would like to suggest creating a new NPM project for the v2.. too many people have already downloaded V1 and this is a fundamental breaking change |
@mpneuried I agree with @philmander; returning an error object here is a non-optimal solution. Anything in the nodejs ecosystem that deals in ESOMETHING errors will throw an ESOMETHING error, but I'm not aware of a single component/module that returns an error object. It would make a lot more sense to return null, or at the least, undefined. I can't get on board with the choice to return an object that the user didn't ask for, appreciate the effort very much, but a poor choice imho. |
Version |
Hey,
I cant understand why this is happening:
it ALWAYS go into the if(!erro){ } when err is null and cachepage is {} .
i dont understand whats the issue,
The text was updated successfully, but these errors were encountered: