Cache::RamDisk

Sharing of Perl Objects Between Processes on Several RAM Drives
Download

Cache::RamDisk Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Martin Haase-Thomas
  • Publisher web site:
  • http://search.cpan.org/~maht/

Cache::RamDisk Tags


Cache::RamDisk Description

Sharing of Perl Objects Between Processes on Several RAM Drives Cache::RamDisk is a Perl module that provides multi-process applications with a means of sharing Perl objects between the processes while trying to avoid the inconveniences inherent to other IPC tools:1. Message queues are extremely fast, but extremely limited too.2. Shared memory is perhaps even faster, but it came out for me to be an at least hairy problem trying to store several references all in one segment.3. Sockets are reliable, but require a second communication endpoint and yet another server process.But a file is a file is a file.The package collects as much ramdisks to a bundle as possible and necessary to hold the required user space, depending on the respective parameters under which the system's individual kernel had been compiled. The system user and group who owns the cache can be specified for the whole rd bunch, say cache.SYNOPSYSApplication start phase: use Cache::RamDisk::Functions; cache_install( { 'Base' => '/tmp/rd', 'Size' => 16, 'INodes' => 1024, 'SIndex' => { 'fie' => 8, 'foe' => 64, 'fum' => 512 }, 'ShMem' => 'RdLk', 'Keys' => { 'fie' => 50, 'foe' => 200, 'fum' => 4000 }, 'User' => 'apache', 'Group' => 'apache' } );Content handler code: use MyApp::Fie; my $fie = MyApp::Fie->new (12345); print $fie->{'some_field'};Object code: package MyApp::Fie; use Cache::RamDisk; sub new { my ($class, $id) = @_; my $c = Cache::RamDisk->new ('/tmp/rd', CACHE_LRU); my $self = $c->get({'fie' => $id})->{'fie'}->{$id} || do { # perform some db logics $self = $sth->fetchrow_hashref; bless $self, $class; $c->put({'fie' => { $id => $self } }); } $self; }Later on in a cgi script: use CGI qw(:html); use Cache::RamDisk::Functions; my $s = cache_status ('/tmp/rd'); print "Number of items for 'fie': ".$s->key_stat('fie'), br;On application shutdown: cache_remove ('/tmp/rd'); Requirements: · Perl


Cache::RamDisk Related Software