如何在IBM Worklight中缓存数据?

时间:2022-01-27 22:09:47

We have developed a hybrid mobile application using IBM worklight. In our application we have used pagination. Pagination is based on the scrolling. If the user scrolls down then the next page of data will be loaded through AJAX call. I have four tabs each having different type of data which will be opened one by one if it is swiped. Consider that I'm in the 1st tab now and navigating to the 2nd tab. If I come back to 1st tab Data will be fetched again from the server. I don't want this to happen. So I want to cache the data. Is there any way to cache data in IBM worklight ? If I cache will I be able to handle the pagination also ?

我们使用IBM worklight开发了一个混合移动应用程序。在我们的应用程序中,我们使用了分页。分页基于滚动。如果用户向下滚动,则下一页数据将通过AJAX调用加载。我有四个选项卡,每个选项卡都有不同类型的数据,如果刷卡,将逐个打开。考虑一下我现在处于第一个选项卡并导航到第二个选项卡。如果我回到第一个选项卡,将再次从服务器获取数据。我不希望这种情况发生。所以我想缓存数据。有没有办法在IBM worklight中缓存数据?如果我缓存我还能处理分页吗?

2 个解决方案

#1


1  

One of the features in Worklight is called JSONStore.
This feature allows you to store data locally in the device to be retrieved at any time (as well as be synced with the server and be encrypted, but those are less related here).

Worklight中的一个功能称为JSONStore。此功能允许您在任何时间将数据本地存储在要检索的设备中(以及与服务器同步并加密,但这些相关性较低)。

This way you could store related data to each of the tabs and use it when required. - JSONStore performance (search for pagination)

这样,您可以将相关数据存储到每个选项卡,并在需要时使用它。 - JSONStore性能(搜索分页)

#2


1  

Also another thing to consider is that JSONStore is not available on all the OS platforms. There are other available options such as Encrypted cache, local storage and so on.

另外需要考虑的是JSONStore并非在所有操作系统平台上都可用。还有其他可用选项,如加密缓存,本地存储等。

Here is the link for comparision

这是比较的链接

http://www-01.ibm.com/support/knowledgecenter/#!/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/devref/c_jsonstore_overview.html

You might want to pick up a common storage mechanism in case you might want to support a range of OS but yet have a common code base which will help out eventually in time savings developing cross platform apps.

您可能希望选择一种通用的存储机制,以防您可能希望支持一系列操作系统,但却拥有一个通用代码库,这将有助于最终节省开发跨平台应用程序的时间。

For example for BlackBerry 10, I had to revert to common storage facility offered by HTML 5 web technologies and use that as a base. But if you plan on supporting only Android, iOS or for that matter Windows 8, then JSON store is the best way to go!

例如,对于BlackBerry 10,我不得不恢复HTML 5 Web技术提供的通用存储设施,并将其作为基础。但如果您计划仅支持Android,iOS或Windows 8,那么JSON商店是最好的方式!

#1


1  

One of the features in Worklight is called JSONStore.
This feature allows you to store data locally in the device to be retrieved at any time (as well as be synced with the server and be encrypted, but those are less related here).

Worklight中的一个功能称为JSONStore。此功能允许您在任何时间将数据本地存储在要检索的设备中(以及与服务器同步并加密,但这些相关性较低)。

This way you could store related data to each of the tabs and use it when required. - JSONStore performance (search for pagination)

这样,您可以将相关数据存储到每个选项卡,并在需要时使用它。 - JSONStore性能(搜索分页)

#2


1  

Also another thing to consider is that JSONStore is not available on all the OS platforms. There are other available options such as Encrypted cache, local storage and so on.

另外需要考虑的是JSONStore并非在所有操作系统平台上都可用。还有其他可用选项,如加密缓存,本地存储等。

Here is the link for comparision

这是比较的链接

http://www-01.ibm.com/support/knowledgecenter/#!/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/devref/c_jsonstore_overview.html

You might want to pick up a common storage mechanism in case you might want to support a range of OS but yet have a common code base which will help out eventually in time savings developing cross platform apps.

您可能希望选择一种通用的存储机制,以防您可能希望支持一系列操作系统,但却拥有一个通用代码库,这将有助于最终节省开发跨平台应用程序的时间。

For example for BlackBerry 10, I had to revert to common storage facility offered by HTML 5 web technologies and use that as a base. But if you plan on supporting only Android, iOS or for that matter Windows 8, then JSON store is the best way to go!

例如,对于BlackBerry 10,我不得不恢复HTML 5 Web技术提供的通用存储设施,并将其作为基础。但如果您计划仅支持Android,iOS或Windows 8,那么JSON商店是最好的方式!