Sys::Ramdisk - Create and nuke RAM disks on various systems
use Sys::Ramdisk; my $ramdisk = Sys::Ramdisk->new( size => "100m", dir => "/tmp/ramdisk", ); $ramdisk->mount(); # Use ramdisk on /tmp/ramdisk ... $ramdisk->unmount();
Most Unix systems provide RAM disks, although every OS/filesystem flavor seems to have its own interface to it. Sys::Ramdisk provides a system-agnostic interface to it, by abstracting the nitty gritty of the particular implementation.
new()
Constructor, optional arguments are
size
The size of the RAM disk, defaults to 100m.
dir
The directory the RAM disk is going to be mounted under, defaults to a temporary directory, created on demand and returned by the dir() method later
cleanup
Set this to true if you want the object destructor unmount the yroot when the object goes out of scope. Defaults to true.
mount()
Mount the RAM disk.
unmount()
Unmount the RAM disk.
dir()
Set or get the name of the directory the RAM disk will be mounted under. Note that some operating systems mount the RAM disk under a different directory nevertheless (e.g. OSX), make sure to check $ramdisk->dir() after running mount() to figure out where it actually landed.
Currently, only Linux and OSX are supported.
Copyright 2010 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
2010, Mike Schilli <cpan@perlmeister.com>
To install Sys::Ramdisk, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sys::Ramdisk
CPAN shell
perl -MCPAN -e shell install Sys::Ramdisk
For more information on module installation, please visit the detailed CPAN module installation guide.