本文介绍了如何在 Angular $cacheFactory 中定义缓存的过期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了有关 Angular '$cacheFactory' 的内容,但找不到任何有关为缓存内容设置到期日期的文档.

I read about the Angular '$cacheFactory' but could not find any documentation on setting an expiration date for cached content.

如果我想将所有 GET 请求缓存 30 秒,如何在$cacheFactory"中定义它或者我是否需要自己扩展功能.

What if I want to cache all GET requests for 30 seconds, how to I define this in the '$cacheFactory' or do I need to extend the functionality myself.

推荐答案

我也遇到了这个问题.默认的 $cacheFactory 没有生存时间(TTL).

I faced the problem too. The default $cacheFactory have no time to live (TTL).

您需要自己实现这一点.但在此之前,您可以环顾四周,看看是否有人已经这样做了:

You will need to implement this yourself. But before, you could give a look around, to see if someone already did it :

这个看起来很完整 - http://jmdobry.github.io/angular-cache/

This one look pretty complete - http://jmdobry.github.io/angular-cache/

如果您真的想实现自己的解决方案(通过实现自己的 $cacheFactory)并需要一些帮助,请随时询问.

If you really want to implement your own solution (by implementing your own $cacheFactory) and need some help, feel free to ask.

希望它能给你一些线索.

Hope it gave you some clue.

这篇关于如何在 Angular $cacheFactory 中定义缓存的过期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 10:17