You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
As soon as I call user.toJSON(), it mutates the user object in the cache as well. Next time this code runs await Cache.remember will not return the model, but simply the toJSON-converted array.
Expected behaviour
The object stored in the cache should be immutable.
I am using the object cache store.
The text was updated successfully, but these errors were encountered:
MZanggl
changed the title
toJSON() mutates object in cache
toJSON() mutates object in cache
Jan 30, 2019
I wish this library could meet your expected behavior, but I can't deserialize back Class objects to it original form. So what you get is what you would expect from JSON.parse(JSON.stringify(user))
What can I guarantee now if you update the package, is that you get the same value on first run of Cache.remember when value is not cached yet.
Simple example:
Problem
As soon as I call
user.toJSON()
, it mutates theuser
object in the cache as well. Next time this code runsawait Cache.remember
will not return the model, but simply thetoJSON
-converted array.Expected behaviour
The object stored in the cache should be immutable.
I am using the object cache store.
The text was updated successfully, but these errors were encountered: