Skip to content

moment js object is not saved properly #261

@MarcoAbi

Description

@MarcoAbi

by inserting a momentjs object, the cache will serialize it and, upon retrieval, only the string representation can be get.

Expected behaviour: the moment object is retrieved instead of its string representation.

Steps to reproduce:

var cacheOptions = {};
cacheOptions.storageMode = cacheOptions.storageMode || 'sessionStorage';
cacheOptions.deleteOnExpire = cacheOptions.deleteOnExpire || 'aggressive';
cacheOptions.recycleFreq = cacheOptions.recycleFreq || 60000;

console.log("creating cache: mm");
CacheFactory.createCache("mm", cacheOptions);
var cache = CacheFactory.get("mm");

var m = moment();
console.log(m);
cache.put("m", m);
var m1 = cache.get("m");
console.log(m1);

the code above will prints:

r {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: C, _d: Wed Jun 14 2017 00:21:53 GMT+0200 (CEST)…}

2017-06-13T22:21:53.672Z

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions