File perl-MLDBM-Sync.spec of Package perl-MLDBM-Sync
#
# spec file for package perl-MLDBM-Sync
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: perl-MLDBM-Sync
Version: 0.30
Release: 0
%define cpan_name MLDBM-Sync
Summary: Safe Concurrent Access to Mldbm Databases
License: CHECK(GPL-1.0+ or Artistic-1.0)
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/MLDBM-Sync/
Source0: https://cpan.metacpan.org/authors/id/C/CH/CHAMAS/%{cpan_name}-%{version}.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(MLDBM) >= 1
Requires: perl(MLDBM) >= 1
%{perl_requires}
%description
This module wraps around the MLDBM interface, by handling concurrent access
to MLDBM databases with file locking, and flushes i/o explicity per
lock/unlock. The new [Read]Lock()/UnLock() API can be used to serialize
requests logically and improve performance for bundled reads & writes.
my $sync_dbm_obj = tie %cache, 'MLDBM::Sync', '/tmp/syncdbm', O_CREAT|O_RDWR, 0640;
# Write locked critical section
$sync_dbm_obj->Lock;
... all accesses to DBM LOCK_EX protected, and go to same tied file handles
$cache{'KEY'} = 'VALUE';
$sync_dbm_obj->UnLock;
# Read locked critical section
$sync_dbm_obj->ReadLock;
... all read accesses to DBM LOCK_SH protected, and go to same tied files
... WARNING, cannot write to DBM in ReadLock() section, will die()
... WARNING, my $v = $cache{'KEY'}{'SUBKEY'} will trigger a write so not safe
... to use in ReadLock() section
my $value = $cache{'KEY'};
$sync_dbm_obj->UnLock;
# Normal access OK too, without explicity locking
$cache{'KEY'} = 'VALUE';
my $value = $cache{'KEY'};
MLDBM continues to serve as the underlying OO layer that serializes complex
data structures to be stored in the databases. See the MLDBM BUGS section
for important limitations.
MLDBM::Sync also provides built in RAM caching with Tie::Cache md5 key
checksum functionality.
%prep
%setup -q -n %{cpan_name}-%{version}
find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
%{__make} %{?_smp_mflags}
%check
%{__make} test
%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
%files -f %{name}.files
%defattr(-,root,root,755)
%doc CHANGES Makefile README
%changelog