XAS::Lib::Lockmgr::Flom - Use the FLoM lock manager for locking.
use XAS::Lib::Lockmgr; my $key = '/var/lock/wpm/alerts'; my $lockmgr = XAS::Lib::Lockmgr->new(); $lockmgr->add( -key => $key, -driver => 'Flom', -args => { port => 9506, address => '127.0.0.1', timeout => 10, attempts => 10, } ); if ($lockmgr->try_lock($key)) { $lockmgr->lock($key); ... $lockmgr->unlock($key); }
This class uses the FLoM distributed lock manager to manage locks. This leverages the atomicity of using a centralized lock manager and allows for discretionary locking of resources.
This module uses the following fields in -args.
The number of attempts to aquire the lock. The default is 30.
The number of seconds to wait between lock attempts. The default is 30.
The address of the host that is presenting the lock daemon. Defaults to 127.0.0.1.
The port that the lock daemon is listening on. Defaults to 28015.
Attempt to aquire a lock. Returns TRUE for success, FALSE otherwise.
Remove the lock. Returns TRUE for success, FALSE otherwise.
Check to see if a lock could be aquired. Returns FALSE if not, TRUE otherwise.
Returns the exceptions that you may not want to continue lock attemtps if triggered.
Kevin L. Esteb, <kevin@kesteb.us>
Copyright (c) 2012-2016 Kevin L. Esteb
This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.
To install XAS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XAS
CPAN shell
perl -MCPAN -e shell install XAS
For more information on module installation, please visit the detailed CPAN module installation guide.