angular 2 是否有 cacheFactroy?
Does angular 2 have a cacheFactroy?
不知道angular2有没有cacheFactory?如果有,谁能提供一些技术教程?简单介绍一下使用方法,将不胜感激!
P.S: 现在,我正在尝试将我的 angular1 项目移动到 angular2,我在使用 cacheFactory 时遇到了问题。
Angular2 没有像 Angular1 那样的 cacheFactory,但您可以使用 CacheFactory 作为替代品。
在 angular2 中你可以使用这个 CacheFactory 节点模块,下面的代码是使用这个 CacheFactory 的例子。
import { CacheFactory } from 'cachefactory';
const cacheFactory = new CacheFactory();
let cache;
// Check whether cache metadata has been initialized
// on every page refresh.
if (!cacheFactory.exists('my-cache')) {
// Create the cache metadata. Any previously saved
// data will be loaded.
cache = cacheFactory.createCache('my-cache', {
// Delete items from the cache when they expire
deleteOnExpire: 'aggressive',
// Check for expired items every 60 seconds
recycleFreq: 60 * 1000
});
}
cache.put('/books/1', { title: 'BookOne', id: 1 });
不知道angular2有没有cacheFactory?如果有,谁能提供一些技术教程?简单介绍一下使用方法,将不胜感激!
P.S: 现在,我正在尝试将我的 angular1 项目移动到 angular2,我在使用 cacheFactory 时遇到了问题。
Angular2 没有像 Angular1 那样的 cacheFactory,但您可以使用 CacheFactory 作为替代品。
在 angular2 中你可以使用这个 CacheFactory 节点模块,下面的代码是使用这个 CacheFactory 的例子。
import { CacheFactory } from 'cachefactory';
const cacheFactory = new CacheFactory();
let cache;
// Check whether cache metadata has been initialized
// on every page refresh.
if (!cacheFactory.exists('my-cache')) {
// Create the cache metadata. Any previously saved
// data will be loaded.
cache = cacheFactory.createCache('my-cache', {
// Delete items from the cache when they expire
deleteOnExpire: 'aggressive',
// Check for expired items every 60 seconds
recycleFreq: 60 * 1000
});
}
cache.put('/books/1', { title: 'BookOne', id: 1 });