问题描述
我阅读了有关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/
如果您真的想实现自己的解决方案(通过实现自己的$ 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中的缓存上定义过期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!