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: 
jbrave
Channel Surfer

caching strategy (philosophy)

not really asking a question here, just a comment if anyone wants to discuss

seems like many apps do lots of unnecessary reloading of content from the net. Well, when you first start on an app and you've never done this type of xml based data retrieval programming before, thinking this out is probably not as high a priority as learning and writing the app. I'm contemplating how to bolt a caching system onto the top of my app so that stuff only gets reloaded from the net when requested the first time, or the app is first loaded. If you can imagine what the cumulative cost of hundreds or thousands of clients with a poor caching system is for a company like YouTube for instance, or Netflix you can imagine that at some point unnecessary reloading is costing a hugh amount of money, which someone is paying for somewhere...

I'm not talking about predictive caching, but just storing information locally and only reloading when necessary.

Some ideas off the top of my head:

Use a separate posterlist variable for each category on your poster screen. Storing each posterlist in an roArray means you can use msg.Getindex() of posterscreen to select the to select the already loaded Posterlist:



posterscreen=createObject("roPosterScreen")
listone=loadsearchitems() 'preload the title, description, URL's of searchItems
listtwo=loadfavoriteitems() 'same thing for favorite items
posterlist=[listone,listwo]
posterscreen.SetContentList(Posterlist[0])
port=CreateObject("roMessagePort")
posterscreen.SetPort(port)
posterscreen.show
while true
msg=wait(0,port)
if msg.isListFocused()
posterscreen.SetContentList(posterlist[msg.getIndex()]
end if
end while



There may be errors in the above, since I just wrote it off the top of my head, but maybe you get the idea of what I'm thinking of.

Some mechanism for determining when a user has requested to load the data for the first time and when they are trying to look at the same data again has to be worked out. That's what I'm thinking about now for my own app.

Now of course, That only covers caching xml and posteritems, not the artwork and data files that come over. Well, assuming the artwork files aren't that big, one could probably save that to local memory or USB if they have it, and reload it from there, of course, there would need to be some way to wipe it out, probably want to do that when the app is loaded or better, when the accumulated pile of files is greater than a certain amount, or older than a certain date. Something like



if imageAge <> tooOld then
ImageURl(index)="pkg:/images/temp/image"+index+".png"
else
imageURL(index)="http://servername.com/temp/image"+".png"
end if



to try to throw together a quickee example from the top of my head....

So any philosophical comments?

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
2 REPLIES 2
TheEndless
Channel Surfer

Re: caching strategy (philosophy)

"jbrave" wrote:
That only covers caching xml and posteritems, not the artwork and data files that come over.

The Roku handles caching of images automatically, as long as the URL doesn't change. For caching data files, you can use the GetToFile method of the roUrlTransfer component to save them to tmp: on the first get, then load from there on subsequent requests.

One thing to consider when caching content is that the Roku does have limited memory available to it. The more you cache, the quicker you'll reach that limit, so you'll want to be wary of just how much data you're keeping resident in memory.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
karmacode
Visitor

Re: caching strategy (philosophy)

One thing to consider when caching content is that the Roku does have limited memory available to it. The more you cache, the quicker you'll reach that limit, so you'll want to be wary of just how much data you're keeping resident in memory.


Any idea what that memory limit is?
http://www.connectedtvforum.com
0 Kudos