Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
guidamedia2
Visitor

Caching data to limit requests to API

I am looking for the best caching method. What I am trying to achieve is to store response strings from my API on a daily basis, and some data even longer.

I have been reading about caching data on the Roku, but not really sure what the best solution is. It doesn't sound like it is designed for this.

I put together some simple script to cache the response strings from my api to the registry, and it saves tons of time retrieving it from there, rather than hitting the site again.

I also have been reading about AsyncGetToFile(), but that is dumped, according to what I read, after the channel session is over. (I assume the session is over as soon as the end-user goes to the home screen).

So, if you were to store data daily, weekly, monthly, would you do it, and if so... how?
0 Kudos
7 REPLIES 7
MSGreg
Visitor

Re: Caching data to limit requests to API

I think the only solution is the roRegistry, limited to 16KBytes.
0 Kudos
guidamedia2
Visitor

Re: Caching data to limit requests to API

Yeah, that is what I was thinking. MSGreg, I appreciate you getting back to me on this. I guess most channels are using GetToFile() and store the results per session.
0 Kudos
MSGreg
Visitor

Re: Caching data to limit requests to API

In general, yes I would guess that developers are storing per session to the local file system. Whether you need a cache or not all depends on the exact use of the data (and whether you want it to refresh or not while the channel is running...imagine a channel running all night, for example).

roImageCanvas manages a cache for URLs specified in the data. That is why it also has PurgedCachedImages() function (see here for tips on how to use PurgeCachedImages).

Hope this helps!
0 Kudos
guidamedia2
Visitor

Re: Caching data to limit requests to API

I put this on the back burner for a while, but now I really want to get some data cached. I am using AsyncGetToFile(filename), where filename = "temp:/fred.txt".

AsyncGetToFile() is returning false. What am I doing wrong?
0 Kudos
RokuMarkn
Visitor

Re: Caching data to limit requests to API

The device name for the temp filesystem is "tmp". So your filename should be "tmp:/fred.txt".

--Mark
0 Kudos
guidamedia2
Visitor

Re: Caching data to limit requests to API

Thanks this got me a true result, however I am not getting data from event = wait(timeout%, m.Http.GetPort()), except for the responsecode of 200.

Are there any good examples on how to use this and get xml?
0 Kudos
RokuJoel
Binge Watcher

Re: Caching data to limit requests to API

You don't read the file system with an roURLTransfer object. You would typically use readasciifile("tmp:/fred.txt")

- Joel
0 Kudos