in reply to Re^4: Moving from hashing to tie-ing.
in thread Moving from hashing to tie-ing.
Since the data is static,no locking or updating is required, move the existing "build a hash but don't split the fields" code into a separate script that does that, opens a port and listens. This takes around 3 minutes to do a 2.5 GB file containing ~8 million records on my system.
This server script needn't be complicated as all requests will be of the form:
In each script that you removed the hash building code, replace it with a call to tie the hash, instead of building it.
Create a Tie::Hash module that only implements the TIEHASH and FETCH methods.
The TIEHASH method connects to the listening port (or starts the new script in the background if the port is unavailable and then connects).
The FETCH method checks it's local cache for the request key and if not found, posts the key to the background script and reads back the record, splits it into fields and caches it locally in a hash as an array (ref).
Now,
|
|---|