WebStorage AngularJS module to work with localStorage and sessionStorage based persistence. Data is saved as string if the values is a String object or parsed to JSON if it's an object.
This module is based on lscache (A localStorage-based memcache-inspired client-side caching library. ).
The original idea is to build an adapter to replace $resource and check if the data is in localStorage before use $http, if the data is not there it should call it.
- You need to include the 'webstorage' in your app.
- Include the 'WebStorage' where you want to use it.
- Use it.
Stores the value in localStorage. Expires after specified number of minutes.
key
(string)value
(Object|string)time
(number: optional)
WebStorage.set(key, value, time);
Retrieves specified value from localStorage, if not expired.
key
(string)
WebStorage.get(key);
Removes a value from localStorage.
key
(string)
WebStorage.remove(key);
Check if localStorage is supported in the current browser.
WebStorage.supported();
Removes all WebStorage items from localStorage without affecting other data.
WebStorage.flush();
Appends CACHE_PREFIX so WebStorage will partition data in to different buckets
bucketName
(string)
WebStorage.setBucket(bucketName);
WebStorage.resetBucket();
You can find a list of brownser support here: http://www.quirksmode.org/dom/html5.html