[英]Best way to cache data for certain time
I have a situation where admin has defined both English and Spanish Language at the admin panel . 我遇到这样的情况,管理员在管理面板上同时定义了英语和西班牙语 。 Right now, Whatever the changes he made in admin panel , it is reflecting on the website .
现在,无论他在管理 面板中进行了什么更改,它都反映在网站上 。
My question that when we have different platforms like Android and iOS, Whatever the changes he made in the Admin panel I want it to reflect in the Android as well. 我的问题是,当我们拥有不同的平台(例如Android和iOS)时,无论他在“管理”面板中进行了什么更改,我都希望它也能反映在Android中。 As of now, I have defined both language information in Strings.xml .
到目前为止,我已经在Strings.xml中定义了两种语言信息。
I do not think calling server each time for the Labels is a good idea. 我不认为每次为标签调用服务器都是一个好主意。 If i do, it might slow down the app .
如果我这样做, 可能会使应用程序 变慢 。
In detail, i have a validation message like " Please Enter User Name ". 详细地,我有一条验证消息,例如“ 请输入用户名 ”。 And the admin changed the label in the back-end and made it Enter User Name .
管理员更改了后端的标签,并使其输入用户名 。 Each time calling server to get the information is bad idea.
每次调用服务器获取信息都是一个坏主意。 I would like to save the information or data for certain periods.
我想将信息或数据保存一段时间。 say 2 hours or 24 hours.
说2个小时或24个小时。
What is the best way to achieve this? 实现此目标的最佳方法是什么?
In my opinion the best solution is to keep it in sqlite. 我认为最好的解决方案是将其保留在sqlite中。 You should check version of strings by calling your API when ie application is starting and then update its if necessary.
您应该在应用程序启动时通过调用API来检查字符串的版本,然后在必要时进行更新。
Unfortunatell queries SQLITE every time when user open new activity/fragment might also slow down your app. 每当用户打开新的活动/片段时,不幸的查询SQLITE也会降低您的应用程序的速度。 In my opinion you should keep your map of string in Application Class or in Object (if you use kotlin) - query your sqlite after checking version of your string or when app is starting if API is unavailable.
我认为您应该将字符串映射保留在应用程序类或对象中(如果使用kotlin)-在检查字符串的版本后或在API不可用时启动应用程序时查询sqlite。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.