in reply to Will these functions for use with Storable properly lock my file?
Possibly, another solution could be to use a memory-mapped file, especially if your data can easily fit in your RAM. I am still confused on the exact way to do this. On the one hand, there is :mmap of PerlIO, something like this, but I don't know how to lock this:
my $fh; if( ! open($fh, '>>:mmap', 'file.txt') ){ die "error opening, $!" } select $fh; $| = 1; my $i; while($i++<10){ print $fh "hello $$ at $i\n"; sleep 1; } close $fh;
There is also File::Map which offers locking but from its documentation is not clear to me how to even append to the file and locking blocks. Very likely I am doing something wrong.
If you manage to get this right then it seems to me it will be faster. There are lots of other modules which use a shared-memory space to share data, like Cache::FastMmap
bw, bliako
|
---|