开发者

Appcelerator. Cache JSON output for a short time

I am developing an iOS app that uses a single context architecture. I make frequent calls to my API (PHP) and I want to "cache" the output for as long as the session is active. Right now I am saving the output to a variable that is defined in the app.s.

var contacts = {

    contactsData: null

};

So I do this to save the output, is it really a good 开发者_运维技巧idea? Will it slow things down?

contacts.contactsData = output;

Thankful for all input!


It consist of how big is json file in mb. If device have enough RAM - it is the best way. Also be sure you save decoded json not just request response, so you will not decode it every time.

If json data is too big you must think about some kind of local storage. If Json is always the same (no need to synch every time) save it local.

If you need update it often you can upload extremly needed part with 1 limited request (API config needed) and other data with second background request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜