1Lucy::Store::LockFactorUys(e3rpmC)ontributed Perl DocumeLnutcayt:i:oSntore::LockFactory(3pm)
2
3
4
6 Lucy::Store::LockFactory - Create Locks.
7
9 use Sys::Hostname qw( hostname );
10 my $hostname = hostname() or die "Can't get unique hostname";
11 my $folder = Lucy::Store::FSFolder->new(
12 path => '/path/to/index',
13 );
14 my $lock_factory = Lucy::Store::LockFactory->new(
15 folder => $folder,
16 host => $hostname,
17 );
18 my $write_lock = $lock_factory->make_lock(
19 name => 'write',
20 timeout => 5000,
21 interval => 100,
22 );
23
25 LockFactory is used to spin off interprocess mutex locks used by
26 various index reading and writing components. The default
27 implementation uses lockfiles, but LockFactory subclasses which are
28 implemented using alternatives such as flock() are possible.
29
31 new
32 my $lock_factory = Lucy::Store::LockFactory->new(
33 folder => $folder, # required
34 host => $hostname, # required
35 );
36
37 Create a new LockFactory.
38
39 • folder - A Folder.
40
41 • host - An identifier which should be unique per-machine.
42
44 make_lock
45 my $lock = $lock_factory->make_lock(
46 name => $name, # required
47 timeout => $timeout, # default: 0
48 interval => $interval, # default: 100
49 );
50
51 Return a Lock object, which, once obtain() returns successfully,
52 maintains an exclusive lock on a resource.
53
54 • name - A file-system-friendly id which identifies the resource to
55 be locked.
56
57 • timeout - Time in milliseconds to keep retrying before abandoning
58 the attempt to obtain() a lock.
59
60 • interval - Time in milliseconds between retries.
61
62 make_shared_lock
63 my $lock = $lock_factory->make_shared_lock(
64 name => $name, # required
65 timeout => $timeout, # default: 0
66 interval => $interval, # default: 100
67 );
68
69 Return a Lock object for which shared() returns true, and which
70 maintains a non-exclusive lock on a resource once obtain() returns
71 success.
72
73 • name - A file-system-friendly id which identifies the resource to
74 be locked.
75
76 • timeout - Time in milliseconds to keep retrying before abandoning
77 the attempt to obtain() a lock.
78
79 • interval - Time in milliseconds between retries.
80
82 Lucy::Store::LockFactory isa Clownfish::Obj.
83
84
85
86perl v5.38.0 2023-07-20 Lucy::Store::LockFactory(3pm)