If you have the memory to spare and efficiency is of utmost
importance, then by all means load as much as you can into memory.
If memory is tight or you can deal with longer runtimes
(and more disk IO) then store the data in some
sort of persistant storage (SQL DB, hash tied to a DBM file, etc...).
This is the classic space vs. performance tradeoff. You are
going to have to decide which is more important to you in
your particular circumstances.