From: Don Armstrong Date: Sat, 8 Feb 2014 00:55:52 +0000 (-0800) Subject: add clear cache command X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=0f7a3c326c73863ad3be12e916d7c345aa71a8e1;p=bin.git add clear cache command --- diff --git a/bibtex_to_paper b/bibtex_to_paper index 66fdf09..5ac334e 100755 --- a/bibtex_to_paper +++ b/bibtex_to_paper @@ -90,6 +90,7 @@ GetOptions(\%options, 'bibtex|b=s@', 'bibtex_cache|bibtex-cache|c=s', 'pdfviewer|p=s', + 'clear_cache|clear-cache!', 'papers_directory|papers-directory=s@', 'debug|d+','help|h|?','man|m'); @@ -123,6 +124,9 @@ sub main{ } } + if (exists $options{clear_cache}) { + clear_cache($dbh,$sth); + } my %entries; if (exists $options{build_cache}) { $options{bibtex} //= []; @@ -157,6 +161,12 @@ sub main{ } +sub clear_cache { + my ($dbh,$sth) = @_; + $sth->{clear_papers_cache}->execute(); + $sth->{clear_bibtex_cache}->execute(); +} + sub load_papers_into_database { my ($dbh,$sth,$dir) = @_; @@ -393,6 +403,12 @@ SELECT * FROM bibtex WHERE bibtex_key LIKE ?; EOF select_bibtex_by_file_name => <<'EOF', SELECT * FROM bibtex WHERE file_name = ?; +EOF + clear_papers_cache => <<'EOF', +DELETE FROM papers; +EOF + clear_bibtex_cache => <<'EOF', +DELETE FROM bibtex; EOF ); my $st;