Changelog
Changes since v2.0
registerPlugins
There are three changes:
registerPlugins was imported from stash-it; now it is internally built into cacheInstance.
This method now takes one parameter: array of plugins.
Returned cacheInstance is freezed (using Object.freeze), so that returned object is immutable.
Before:
Now:
It felt more naturally that given cache instance should be able to register plugins on itself.
This method still returns newly created cache instance. Therefore:
getExtensions -> createExtensions
getExtensions was renamed to createExtensions. It also takes an object as an argument. That object is passed (by plugins):
cacheInstance
getPreData
getPostData
Before:
Now:
That happened because testing plugins against getPreData
and getPostData
was hard. Now, that they're passed as dependencies, it is trivial to stub them.
key validation
Key validation happened in adapters (basic one). Now it is moved to stash-it, and is even simpler - checks if key
is a string, throws otherwise. If any storage needs to validate this string further, given adapter should do it.
bugfix with hooks
In stash-it v2, hooks are passed by reference, therefore registering more plugins (with hooks, one by one, not few at a time), registers them on all cache instances. Since v3 this is fixed and each plugin registering (that returns a new cache instance) sets hooks only on the newly returned instance.
ES6
stash-it is still written in ES6, but also stays that way. It is about using the code that current environments use (be it node or browsers). Should you need ES5 code - you need to transpile it yourself.
Last updated