cache autoupdating

Closes #881
Removed a bug where _values and _order of a cache could desync because a key was not removed from _order before appending it again.
Accesses to the cache is now synchronized.