guidamedia2
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2012
08:09 AM
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?
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?
7 REPLIES 7
MSGreg
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2012
02:11 PM
Re: Caching data to limit requests to API
I think the only solution is the roRegistry, limited to 16KBytes.
guidamedia2
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2012
04:47 AM
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.
MSGreg
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2012
06:39 AM
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!
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!
guidamedia2
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2012
04:56 AM
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?
AsyncGetToFile() is returning false. What am I doing wrong?

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2012
08:19 AM
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
--Mark
guidamedia2
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2012
11:02 AM
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?
Are there any good examples on how to use this and get xml?

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2012
11:11 AM
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
- Joel