A cache component for use with Backbone. You can include it in your base app and wrap it. You can also call the methods directly, if you wanted to use it directly in a single view or app for example.
By default the cache uses window.cache store the items.
Options
storageType - optional
This option determines if the class should use window.cache or internally view this.cache.
The valid options are ['window', 'internal']. Defaults to window.
eventHandler - optional
This is for listening for event triggers. If you use a custom event object by extending Backbone.Events you can pass in a reference to it here. Otherwise it will default to using Backbone.Events as the event handler.
Namespace for cache methods
If no namespace is provided to any of the cache methods and events, it will default to using 'global' as the namespace
Create Cache
Create a cache at a specified namespace. If no namespace is passed in, it defaults to using 'global' as the namespace.
Add to cache
Add an item to the cache at the provided key and namespace. If namespace does not exist, createCache will automatically be called.
Remove from cache
Remove an item from the cache at the provided key and namespace.
Clear cache
Removes everything in the cache for the namespace.
Get from cache
Get something from the cache. While an event is thrown with the object returned, its easier to write a quick wrapper method in your base app, or base view to retrieve the item.