Skip to content

Direct reference to stored cache object #5

@Pdrevland

Description

@Pdrevland
...
function getObject() { return { a: { b: true } }; }
var o = cache.get('object', getObject);
o.a.b // => true
o.a = { b: false }
var p = cache.get('object', getObject);
// expected p.a.b => true
p.a.b // => false
...

The expected behaviour of the stored cache object should be what the cache function returns.
Problem probably lies in that the stored cache object being returned as reference rather than value, as is normal JS behaviour, and mutation of non-primitives mutates the reference value.

Easy solution is to clearly state this behaviour in the docs as this might lead to some confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions