From 686623ab687cfd4aaa5b4c156faf65ee75ad4000 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 2 Apr 2017 23:58:04 +0200 Subject: Make sqlite cache size configurable Signed-off-by: Florian Pritz --- lib/App/BorgRestore/DB.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/App/BorgRestore/DB.pm') diff --git a/lib/App/BorgRestore/DB.pm b/lib/App/BorgRestore/DB.pm index a7c5916..e01aee2 100644 --- a/lib/App/BorgRestore/DB.pm +++ b/lib/App/BorgRestore/DB.pm @@ -12,15 +12,16 @@ use Log::Any qw($log); sub new { my $class = shift; my $db_path = shift; + my $cache_size = shift; my $self = {}; bless $self, $class; if (! -f $db_path) { - my $db = $self->open_db($db_path); + my $db = $self->open_db($db_path, $cache_size); $self->{db}->initialize_db(); } else { - $self->_open_db($db_path); + $self->_open_db($db_path, $cache_size); } return $self; @@ -29,10 +30,11 @@ sub new { sub _open_db { my $self = shift; my $dbfile = shift; + my $cache_size = shift; $log->debugf("Opening database at %s", $dbfile); $self->{dbh} = DBI->connect("dbi:SQLite:dbname=$dbfile","","", {RaiseError => 1, Taint => 1}); - $self->{dbh}->do("PRAGMA cache_size=-1024000"); + $self->{dbh}->do("PRAGMA cache_size=-".$cache_size); $self->{dbh}->do("PRAGMA strict=ON"); } -- cgit v1.2.3-24-g4f1b