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

moment js object is not saved properly #261

Open
MarcoAbi opened this issue Jun 13, 2017 · 0 comments
Open

moment js object is not saved properly #261

MarcoAbi opened this issue Jun 13, 2017 · 0 comments

Comments

@MarcoAbi
Copy link

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

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

1 participant