Apache::SharedMem allows you to share data between Apache children processes through the shared memory.
use Apache::SharedMem qw(:lock :status);
my $share = new Apache::SharedMem || die($Apache::SharedMem::ERROR);
$share->set(key => 'some data');
# ...maybe in another apache child
my $var = $share->get(key);
# delete all keys if the total size is larger than $max_size
$share->clear if($share->size > $max_size);
# using an exclusive blocking lock, but with a timeout
my $lock_timeout = 40; # seconds
my $data =...
$share->set(key => $data); # the implicite lock is not overrided
warn('failed to store data in shared memory') if($share->status & FAILURE);
This module make it easier to share data between Apache children processes through shared memory. This module internal functionment is much inspired from IPC::SharedCache, but without any cache management.
The share memory segment key is automatically deduced by the caller package, which means that 2 modules can use same keys without being concerned about namespace clash.
An additionnal namespace is used per application, which means that the same module, with the same namespace used in two applications doesn't clash too. Application distinction is made on two things : the process' UID and DOCUMENT_ROOT (for http applications) or current working directory.
What's New in This Release: [ read full changelog ]
· Major bugfix that made the module unusable under mod_perl