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.
Constructor, optional arguments are
The size of the RAM disk, defaults to 100m.
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
Set this to true if you want the object destructor unmount the yroot when the object goes out of scope. Defaults to true.
Mount the RAM disk.
Unmount the RAM disk.
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 <email@example.com>