The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBM::Deep::File

PURPOSE

This is an internal-use-only object for "" in DBM::Deep. It mediates the low-level interaction with the storage mechanism.

Currently, the only storage mechanism supported is the file system.

OVERVIEW

This class provides an abstraction to the storage mechanism so that the Engine (the only class that uses this class) doesn't have to worry about that.

METHODS

new( \%args )

open()

This method opens the filehandle for the filename in file .

There is no return value.

close()

If the filehandle is opened, this will close it.

There is no return value.

size()

This will return the size of the DB. If file_offset is set, this will take that into account.

set_inode()

This will set the inode value of the underlying file object.

This is only needed to handle some obscure Win32 bugs. It reqlly shouldn't be needed outside this object.

There is no return value.

This takes an optional offset and some data to print.

$offset , if defined, will be used to seek into the file. If file_offset is set, it will be used as the zero location. If it is undefined, no seeking will occur. Then, @data will be printed to the current location.

There is no return value.

read_at( $offset, $length )

This takes an optional offset and a length.

$offset , if defined, will be used to seek into the file. If file_offset is set, it will be used as the zero location. If it is undefined, no seeking will occur. Then, $length bytes will be read from the current location.

The data read will be returned.

DESTROY

When the ::File object goes out of scope, it will be closed.

request_space( $size )

This takes a size and adds that much space to the DBM.

This returns the offset for the new location.

flush()

This flushes the filehandle. This takes no parameters and returns nothing.

is_writable()

This takes no parameters. It returns a boolean saying if this filehandle is writable.

Taken from http://www.perlmonks.org/?node_id=691054/.

copy_stats( $target_filename )

This will take the stats for the current filehandle and apply them to $target_filename . The stats copied are:

  • Onwer UID and GID

  • Permissions

LOCKING

This is where the actual locking of the storage medium is performed. Nested locking is supported.

NOTE: It is unclear what will happen if a read lock is taken, then a write lock is taken as a nested lock, then the write lock is released.

Currently, the only locking method supported is flock(1). This is a whole-file lock. In the future, more granular locking may be supported. The API for that is unclear right now.

The following methods manage the locking status. In all cases, they take a "" in DBM::Deep object and returns nothing.

  • lock_exclusive( $obj )

    Take a lock usable for writing.

  • lock_shared( $obj )

    Take a lock usable for reading.

  • unlock( $obj )

    Releases the last lock taken. If this is the outermost lock, then the object is actually unlocked.