-
-
24 May 2015 09:25:20 UTC
- Distribution: File-Lock-Multi
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (433 / 69 / 0)
- Kwalitee
Bus factor: 0- % Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (11.16KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Class::Accessor
- Fcntl
- File::Temp
- Linux::Fuser
- Params::Classify
- Params::Validate
- Test::Exception
- Test::Fork
- Test::More
- Time::HiRes
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
File::Lock::Multi::MySQL - Lock multiple strings in MySQL to emulate taking out multiple locks on a single string.
DESCRIPTION
This module uses MySQL's
GET_LOCK()
function on multiple strings to emulate taking out multiple locks on a single string.It is very important that database handles are not used to take out any other locks, for your resource or for any other resource! From the MySQL documentation:
"If you have a lock obtained with GET_LOCK(), it is released when you execute RELEASE_LOCK(), execute a new GET_LOCK(), or your connection terminates (either normally or abnormally)."
See the dbh option below for more details.
OPTIONS
In addition to the standard File::Lock::Multi options, the following additional options are available when calling
new()
:- format
-
A sprintf() format string used to come up with the individual lockfile names.
sprintf()
will be passed the file's path and the lock number as the first and second parameters. (Default: "%s.%i"). - dbh
-
Either a database handle, or a "factory" (code reference which returns a new database handle each time it is invoked). Because each MySQL lock is unique to a database handle, and each database handle may only have one lock, you almost always need a fresh database handle to hold onto a lock. Example:
my $lock = File::Lock::Multi::MySQL->new( file => "limited.resource", limit => 5, dbh => sub { DBI->connect("DBI:mysql:", $user, $password) } );
LICENSE
Copyright 2010 Tyler "Crackerjack" MacDonald <japh@crackerjack.net>
This is free software; You may distribute it under the same terms as perl itself.
SEE ALSO
Module Install Instructions
To install File::Lock::Multi, copy and paste the appropriate command in to your terminal.
cpanm File::Lock::Multi
perl -MCPAN -e shell install File::Lock::Multi
For more information on module installation, please visit the detailed CPAN module installation guide.