angular 2有cacheFactroy吗?

0 angular2-services angular

我想知道angular2中是否有cacheFactory?如果有,有人可以提供一些技术教程吗?关于如何使用它的简单介绍将非常感激!

PS:现在,我正在尝试将angular1项目移动到angular2,我遇到了使用cacheFactory的问题.

Kar*_*tel 8

在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 });
Run Code Online (Sandbox Code Playgroud)