Title: Setting undefined as value, getting null back (version 5.1.2) · Issue #330 · node-cache/node-cache · GitHub
Open Graph Title: Setting undefined as value, getting null back (version 5.1.2) · Issue #330 · node-cache/node-cache
X Title: Setting undefined as value, getting null back (version 5.1.2) · Issue #330 · node-cache/node-cache
Description: I'm using node-cache 5.1.2 and this is the little example code that I have: import NodeCache from 'node-cache' const cache = new NodeCache({ stdTTL: 900, checkperiod: 900 / 5, useClones: false, }) cache.set('hello', undefined) const rest...
Open Graph Description: I'm using node-cache 5.1.2 and this is the little example code that I have: import NodeCache from 'node-cache' const cache = new NodeCache({ stdTTL: 900, checkperiod: 900 / 5, useClones: false, }) ...
X Description: I'm using node-cache 5.1.2 and this is the little example code that I have: import NodeCache from 'node-cache' const cache = new NodeCache({ stdTTL: 900, checkperiod: 900 / 5, useClones...
Opengraph URL: https://github.com/node-cache/node-cache/issues/330
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Setting undefined as value, getting null back (version 5.1.2)","articleBody":"I'm using node-cache 5.1.2 and this is the little example code that I have:\n\n```ts\nimport NodeCache from 'node-cache'\n\nconst cache = new NodeCache({\n stdTTL: 900,\n checkperiod: 900 / 5,\n useClones: false,\n})\n\ncache.set('hello', undefined)\nconst restored = cache.get('hello') // incorrectly returns null\n```\n\nI found this [already closed issue](https://github.com/node-cache/node-cache/issues/264), don't know whether it is caused by same thing, but the issue still definitely persists.\n\nIf anyone finds this issue my current workaround is to wrap every data that I store into an object, like this:\n\n```ts\ncache.set('workaround', { value: undefined })\nconst restored = cache.get('workaround').value // correctly returns undefined\n```","author":{"url":"https://github.com/meszaros-lajos-gyorgy","@type":"Person","name":"meszaros-lajos-gyorgy"},"datePublished":"2025-11-20T21:59:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/330/node-cache/issues/330"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:741aec3b-f028-0efc-513c-463a8cd5315a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FD6:42D51:1E79934:295EDBA:6964BE39 |
| html-safe-nonce | d1773d4cc73290bf359dec30ba2ec55007005ccfe6ced0181c6527602bb01098 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkQ2OjQyRDUxOjFFNzk5MzQ6Mjk1RURCQTo2OTY0QkUzOSIsInZpc2l0b3JfaWQiOiI1NDQ5MzIyOTk1MDM0NDA2NDU3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 762c7d7fd87d8d72aa33a177846e39af2e0620a5981d7687e1e4b73f6b40af2e |
| hovercard-subject-tag | issue:3649274325 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/node-cache/node-cache/330/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a9c5ff8ec26e9f1aec4523f061981edbe6b270893caf3c6d98b346edb9c2248e/node-cache/node-cache/issues/330 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a9c5ff8ec26e9f1aec4523f061981edbe6b270893caf3c6d98b346edb9c2248e/node-cache/node-cache/issues/330 |
| og:image:alt | I'm using node-cache 5.1.2 and this is the little example code that I have: import NodeCache from 'node-cache' const cache = new NodeCache({ stdTTL: 900, checkperiod: 900 / 5, useClones: false, }) ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | meszaros-lajos-gyorgy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9917306ebdf5f9f30d13ede7b74f08a45b5f12b401ce3e4bfabd895ea0ca0ada |
| turbo-cache-control | no-preview |
| go-import | github.com/node-cache/node-cache git https://github.com/node-cache/node-cache.git |
| octolytics-dimension-user_id | 54621913 |
| octolytics-dimension-user_login | node-cache |
| octolytics-dimension-repository_id | 2599450 |
| octolytics-dimension-repository_nwo | node-cache/node-cache |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 2599450 |
| octolytics-dimension-repository_network_root_nwo | node-cache/node-cache |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 020ceddb26807bba62dcfb410905847d63243ff5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width