角度缓存可以这样设置:
app.service('myService', function ($angularCacheFactory) {
// This cache will sync itself with localStorage if it exists, otherwise it won't. Every time the
// browser loads this app, this cache will attempt to initialize itself with any data it had
// already saved to localStorage (or sessionStorage if you used that).
var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
maxAge: 900000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 3600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
storageMode: 'localStorage' // This cache will sync itself with `localStorage`.
});
});
据我了解,如果 storageMode 设置为“localStorage”,那么它将处理备份到 localstorage 本身。
我已经将角度 LocalStorageModule 用于其他事情。
我设置 localStoragePolyfill 并使用 LocalStorageModule 有什么优势吗?