#Backbone.speed_cache 0.2 May be freely distributed under the MIT license
sync code & ideas adopted from: Backbone.memoized_sync 0.1 by Pablo Villalba for the Teambox project distributed under the MIT license
This modified version changes the behavior for 'read' requests to the following:
- Check if we have it in localStorage.
- If we have it, then...
- We call the success function with the cached data
- We request new data with an AJAX request, which calls the success function again if the data is different from the cache
- If we don't have it, we do a classic AJAX request and save its results to localStorage
All Data stored in localStorage is encrypted.
- Inlcude backbone.speed_cache.js
- Call Backbone.secureStorage.setEncKey(key) with an user specific key as soon as possible. Until then, data is kept in memory only.
Dependencies: Tea.js (included in repository)
- Including this file will override the default backbone sync method.
- Until an encryption key is provided, data is only kept in memory.
- Simple cache clearing method DELETES ALL local storage after 100 cache entries.
- Modeled after Backbone 0.9.2