I think kyle was right, what you want is
Memoize
This caches the result of a function by storring its return value in a hash, so the next time you call the function with the same parameters it will look up the return value in the hash and return that for you, rather then run the whole thing again.
It also gives you the option to list the full hash so you can shove that in a file or database and load it again the next time you start your script resulting in lightning fast performance of a normally very slow fucntion, assuming you use the same input, which you must or caching makes no sense at all.