in reply to Re^2: Cache commands output
in thread Cache commands output

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.

Replies are listed 'Best First'.
Re^4: Cache commands output
by kyle (Abbot) on Oct 20, 2008 at 16:14 UTC

    One difference between using Memoize and Cache::FileCache is that the former defaults to caching forever while the latter can have an expiration time. The OP seems to be looking for some kind of expiration in the implementation. To do that with Memoize, I think you'd have to import unmemoize and write the expiration manually (but I could be wrong).