[AngualrJS] Using Angular-Cache for caching http request
Check the website: https://jmdobry.github.io/angular-cache/#using-angular-cache-with-http
Install:
npm install --save angular-cache
  getServiceDetail( serviceId = "mock" ) {
    if(!this.CacheFactory.get(`${this.prefix}.${serviceId}`)){
        this.$http.defaults.cache = this.CacheFactory(`${this.prefix}.${serviceId}`, {
            maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes
            cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour
            deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire
        });
    }
    return this.$http.get( `${this.CONFIG.BACKEND_API_URL}/services/${serviceId}/details`,
    {
        cache: this.CacheFactory.get(`${this.prefix}.${serviceId}`)
    } )
               .then( ( res ) => {
                   return res.data.serviceDetail;
               }, ( err ) => {
                 this.$log.debug( `ServiceDetails --> getServiceDetail err: Cannnot get detail data: ${JSON.stringify( err, null, 3 )}` );
                 throw err;
               } );
  }
}
[AngualrJS] Using Angular-Cache for caching http request的更多相关文章
- Data caching per request in Owin application
		Data caching per request in Owin application 解答1 Finally I found OwinRequestScopeContext. Very simpl ... 
- spring cloud Bug之was unable to refresh its cache! status = Cannot execute request on any known server
		可能原因: 1.application.yml server: port: 10001spring: application: name: microservice-consumer-movieeur ... 
- was unable to refresh its cache! status = Cannot execute request on any known server
		出现这种错误是因为: Eureka服务注册中心也会将自己作为客户端来尝试注册它自己,所以我们需要禁用它的客户端注册行为. 在 yml中设置 eureka.client.register-with-eu ... 
- [转] KVM storage performance and cache settings on Red Hat Enterprise Linux 6.2
		Almost one year ago, I checked how different cache settings affected KVM storage subsystem performan ... 
- [转] KVM I/O slowness on RHEL 6
		KVM I/O slowness on RHEL 6 http://www.ilsistemista.net/index.php/virtualization/11-kvm-io-slowness-o ... 
- http header cache-control (request和response区别)
		摘要:(1)网络服务会根据 request的header中的 cache-control策略设置response的cache-control策略 1 response cache-control 和 ... 
- 请求方式:request和 get、post、put
		angular 的 http 多了 Request, Headers, Response ,这些都是游览器的"新特性" Fetch API. Fetch API 和以前的 xmlh ... 
- Page.Cache
		https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.page.cache?view=netframework-4.8 Gets the ... 
- 025-缓存Cache
		如果每次进入页面的时候都查询数据库生成页面内容的话,如果访问量非常大,则网站性能会非常差.而如果只有第一次访问的时候才查询数据库生成页面内容,以后都直接输出内容,则能提高系统性能.这样无论有多少人访问 ... 
随机推荐
- Bloom Filter 算法具体解释
			Bloom Filter 算法 Bloom filter是由Burton Bloom 在1970年提出的,其后在P2P上得到了广泛的应用.Bloom filter 算法可用来查询某一数据是否在某一数据 ... 
- Dynamics CRM 2016 使用Plug-in Trace Log调试插件
			1.写插件 首先,让我们写一个简单的插件来测试新插件跟踪日志功能.请注意,在下面的示例代码中,我们增加ITracingService的一个实例,以及记录有关插件的执行信息记录的一些键值: 2.注册插件 ... 
- CSS基础知识笔记(三)
			继承 继承是一种规则,它允许样式不仅应用于某个特定html标签元素,而且应用于其后代.比如下面代码:如某种颜色应用于p标签,这个颜色设置不仅应用p标签,还应用于p标签中的所有子元素文本,这里子元素为s ... 
- Sass函数--颜色函数--RGB颜色函数
			RGB颜色函数-RGB()颜色函数 主要分为 RGB , HSL 和 Opacity 三大函数,当然其还包括一些其他的颜色函数,比如说 adjust-color 和 change-color 等.1. ... 
- java 面对对象(抽象 继承 接口 多态)
			什么是继承? 多个类中存在相同属性和行为时,将这些内容抽取到单独一个类中,那么多个类无需再定义这些属性和行为,只要继承那个类即可. 多个类可以称为子类,单独这个类称为父类.超类或者基类. 子类可以直接 ... 
- hdu 1234
			Problem Description 每天第一个到机房的人要把门打开,最后一个离开的人要把门关好.现有一堆杂乱的机房签 到.签离记录,请根据记录找出当天开门和关门的人. Input 测试输入的第一行 ... 
- mongodb内嵌文档的查询
			本文转自:http://blog.163.com/wm_at163/blog/static/1321734902012526103825481/ 1 > db.blog.findOne() { ... 
- 安装laravel
			# 安装laravel 安装composer #安装 curl -sS https://getcomposer.org/installer | php #添加到PATH sudo mv compose ... 
- 【Nutch2.2.1源代码分析之5】索引的基本流程
			一.各个主要类之间的关系 SolrIndexerJob extends IndexerJob 1.IndexerJob:主要完成 2.SolrIndexerJob:主要完成 3.IndexUtil:主 ... 
- a标签加绝对定位在图片上面,a的链接和块状属性block失效,而且是所有IE版本都失效的
			谷歌和火狐浏览器下测试是正常的,IE下鼠标移过logo是没有超链接的提示的 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitio ... 
