Best practice for caching

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
fhx
Posts: 6
Joined: Wed Jul 09, 2008 7:22 pm

Best practice for caching

Post by fhx » Tue Aug 12, 2008 8:11 pm

Greetings,

I want to cache values from the DB (mainly lookup table values that are not changed); I have seen in the query bulider the checkbox: "Cache Record Set". I don't want to use the query builder.

What is the best practice to create cached record sets? Should I create global variables that will contain these values or does anyone else has a better idea?

Best,
Frank

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Wed Aug 13, 2008 12:39 am

I don't know how you're planning on using this, but here are a couple of ideas off the top of my head:

1. You can store the lookup values as custom properties of an object. Just grab them once, save them, and then look them up from the custom property after that.

set the xyz of card "prefs" to someData
put the xyz of card "prefs" into tNewVariable

2. Alternately, you can store them as local variables in the stack script and have an accessor function there to retrieve them:

local sLookupArray
on CachedValue pValue
return sLookupArray[pValue]
end CachedValue

Post Reply