XML::Comma::Pkg::MySQL_Simple_Lock

XML::Comma::Pkg::MySQL_Simple_Lock is a simple one-time-use lock coordinated by db.
Download

XML::Comma::Pkg::MySQL_Simple_Lock Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Brian Szymanski
  • Publisher web site:
  • http://search.cpan.org/~brianski/XML-Comma-1.998/lib/XML/Comma/docs/faq.pod

XML::Comma::Pkg::MySQL_Simple_Lock Tags


XML::Comma::Pkg::MySQL_Simple_Lock Description

XML::Comma::Pkg::MySQL_Simple_Lock is a simple one-time-use lock coordinated by db. XML::Comma::Pkg::MySQL_Simple_Lock is a simple one-time-use lock coordinated by db.SYNOPSIS use XML::Comma::Pkg::MySQL_Simple_Lock; my $lock = XML::Comma::Pkg::MySQL_Simple_Lock->new ( "foo", 10 ); die "couldn't get lockn" unless $lock; undef $lockComma applications can be spread across multiple machines in a cluster, as long as core database operations are all pointed at a centralized server. This module provides advisory locking capabilities to Comma programmers working in such an environment.MySQL exposes a very simple advisory locking API, the functions GET_LOCK() and RELEASE_LOCK(). This module provides a very simple, object-oriented abstraction on top of these functions. Here is a simple test script: #!/usr/bin/perl -w use strict; $|++; use XML::Comma::Pkg::MySQL_Simple_Lock; &do_lock; print "waiting outside scope... "; my $junk = ; sub do_lock { my $lock = XML::Comma::Pkg::MySQL_Simple_Lock->new ( "foo", 1 ); die "couldn't get lockn" unless $lock; print "$lockn"; print "waiting inside scope... "; my $junk = ; }The new() method expects a key_string argument, which is used to "name" the lock, and an optional timeout argument. timeout should be given in seconds, and defaults to 86400, or one day.new() returns a lock object on success, or undef on failure.The lock is held as long as a reference to the MySQL_Simple_Lock object is being held. When all references to the object go out of scope, the object is destroyed and the lock is automatically released. It is a good idea to explicitly undef any lock objects, to make life easier for maintenance programmers.Each MySQL_Simple_Lock object is a one-time-use construct. To request a new lock, make a new object.Each MySQL_Simple_Lock object occupies a database connection as long as it is held.Requirements:· Perl Requirements: · Perl


XML::Comma::Pkg::MySQL_Simple_Lock Related Software