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

Get method value is wrong, when the value type is Map #64

Closed
luozhanhong opened this issue Jul 8, 2016 · 2 comments
Closed

Get method value is wrong, when the value type is Map #64

luozhanhong opened this issue Jul 8, 2016 · 2 comments

Comments

@luozhanhong
Copy link

var NodeCache = require("node-cache");
var myCache = new NodeCache();

var map = new Map();
map.set(1, 1);
console.log(map);
// Map { 1 => 1 }

myCache.set("myKey", map, function (err, success) {
    if (!err && success) {
        console.log(success);
        // true
    }
});

myCache.get("myKey", function (err, value) {
    if (!err) {
        if (value == undefined) {
            console.log("undefined");
        } else {
            console.log(value);
            // Map {}
        }
    }
});
@luozhanhong luozhanhong changed the title Get method value error , when the value type is Map Get method value is wrong, when the value type is Map Jul 8, 2016
@mpneuried mpneuried self-assigned this Jul 8, 2016
@mpneuried
Copy link
Contributor

var myCache( { useClones: false } );

See options.

  • useClones: (default: true) en/disable cloning of variables. If true you'll get a copy of the cached variable. If false you'll save and get just the reference.
    Note: true is recommended, because it'll behave like a server-based caching. You should set false if you want to save complex variable types like functions, promises, regexp, ...

@luozhanhong
Copy link
Author

Thank you.

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

No branches or pull requests

2 participants