Skip to content
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

canched value can only be object #290

Closed
tjx666 opened this issue Apr 17, 2023 · 3 comments
Closed

canched value can only be object #290

tjx666 opened this issue Apr 17, 2023 · 3 comments

Comments

@tjx666
Copy link

tjx666 commented Apr 17, 2023

image

image

@isaacs
Copy link
Owner

isaacs commented Apr 17, 2023

Yes, it uses undefined as a signal in some cases to mean that the item is not found, and this will cause incorrect behavior. Don't put undefined in the cache. If you want a key to be undefined, delete it.

I suppose the set method could be changed to allow cache.set(key, undefined) to be an alias for cache.delete(key), would that be to your liking?

The downside, I guess, would be if you wanted cache.has(key) to return true?

@isaacs
Copy link
Owner

isaacs commented Apr 17, 2023

Another option would be to use a special object that means "no value here", so it would "have" the object, but still return undefined from cache.get?

@tjx666
Copy link
Author

tjx666 commented Apr 17, 2023

Yes, allow set value to be V | undefined is enough for me

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

No branches or pull requests

2 participants