什么是$ cacheFactory?cacheFactory

由网友(陌然忆尘)分享简介:我可以找到绝对没有的信息究竟是什么 $ cacheFactory 以及它是如何可以在你的应用程序非常有用。I can find absolutely no information on what exactly $cacheFactory is and how it can be useful in your app...

我可以找到绝对没有的信息究竟是什么 $ cacheFactory 以及它是如何可以在你的应用程序非常有用。

I can find absolutely no information on what exactly $cacheFactory is and how it can be useful in your application.

该角文档说

工厂构建缓存对象,并可以访问他们。 - 的 $ cacheFactory

"Factory that constructs cache objects and gives access to them." -- $cacheFactory

嗯,这是不是在所有有用的,这是什么意思?似乎没有要上谷歌任何事。

Well, that wasn't at all helpful, what does that mean? There doesn't seem to be anything on Google either.

有人可以解释的这是什么&安培; 什么时候会非常有用

Can someone please explain What it is & When can it be useful.

先谢谢了。

推荐答案

哦$ cacheFactory很简单,因为我理解它:

Oh the $cacheFactory is simple as i understand it :

如果您需要检索常量数据,例如像城市的列表的请求。

If you have a request to retrieve constant data for example like a list of cities.

这不是一个很好的模式,每次用户在表单上走到哪里,他必须选择一个城市从服务器获取该列表!

It's not a good pattern to get this list from the server each time the user go on a form where he has to select a city !

所以,你必须缓存此列表中。该cacheFactory是该做的!

So you have to cache this list. The cacheFactory is done for that !

如果您正在使用$ http来代替$资源可以enbale缓存就像是:

If you're using $http instead of $resource you can enbale the cache just like that :

$http.get('myUrl', { cache: true })
阅读全文

相关推荐

最新文章