简体   繁体   English

缓存特定时间的最佳方法

[英]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.

相关问题 在Android中缓存数据的最佳方法 - Best Way to Cache Data in Android 在 kotlin 应用程序中安全缓存数据的最佳方法? - Best way to securely cache data in a kotlin app? 建立缓存的最佳方法 - The best way to build cache 即使应用程序被杀死,如何在特定时间内缓存数据? - How to cache data for a certain time even after the app is killed? 在Android中在特定时间显示通知的最佳方法是什么? - What is best way to show notification at a certain time in Android? 除了 ROOM,在 Android 中缓存数据的最佳方法是什么? - What is the best way to cache data in Android other than ROOM? 使用ViewModel和RxJava2在Android中缓存数据的最佳方法 - Best way to cache data in Android with ViewModel and RxJava2 缓存联系人照片的最佳方法 - Best way to cache contacts photo 当您的应用依赖于api请求限制时,从内存和存储中缓存数据的最佳方法? - Best way to cache data from memory and storage when your app is dependent of api request limit? 哪个是从缓存中检索数据然后从RxJava中的网络调用中检索数据的最佳方法?(concat concatEager,merge) - Which is the best way to retrieve data first from a cache then from a network call in RxJava ?(concat concatEager,merge)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM