谷歌排球 - 何时使用Cache.remove和Cache.invalidate [英] Google Volley - when to use Cache.remove and Cache.invalidate

查看:682
本文介绍了谷歌排球 - 何时使用Cache.remove和Cache.invalidate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我凌空整合成一个项目,遇到了标准

I am integrating Volley into a project and came across the standard

[我们在缓存的项目,但要允许用户刷新反正]场景

[We have items in the Cache, but want to allow the User to refresh anyway] Scenario

现在谷歌凌空提供了2种方式来清除缓存中的项目:

Now Google Volley provides 2 ways to clear an item from the Cache:

getRequestQueue().getCache().remove(key);

getRequestQueue().getCache().invalidate(key, fullExpire);

我看着到code和有点惊讶,那废止 fullExpire 设置为true不表现完全像一个呼叫删除(键)

I looked into the code and was a bit surprised, that invalidate with fullExpire set to true doesn't behave exactly like a call to remove(key).

有人可以解释一下使用 fullExpire 删除的好处()

Can somebody explain the benefits of using fullExpire over remove()?

推荐答案

删除意味着你删除的实际缓存数据。

Remove means you are removing the actual cached data.

的Invalidate意味着你只是标记数据为无效。所以凌空将检查与服务器的数据是否仍然有效。全失效确定是否使用数据之前凌空已与服务器验证它

Invalidate means you are just marking the data as invalid. So volley will check with the server whether the data is still valid. The full expire determines whether to use the data before volley has validated it with the server.

详细信息源中:<一href="https://android.googlesource.com/platform/frameworks/volley/+/master/src/com/android/volley/Cache.java">https://android.googlesource.com/platform/frameworks/volley/+/master/src/com/android/volley/Cache.java

这篇关于谷歌排球 - 何时使用Cache.remove和Cache.invalidate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆