about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiStore.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-11 07:20:57 +0000
committerEric Wong <e@80x24.org>2023-10-11 22:10:51 +0000
commit3d490f2b9a8b2934cb386a8649e034c8c6c70bc9 (patch)
tree45e834eed12a38b1a84849b89503834db182a949 /lib/PublicInbox/LeiStore.pm
parent905f07417459f958b394cad1c4ccd86f6f8cce7c (diff)
downloadpublic-inbox-3d490f2b9a8b2934cb386a8649e034c8c6c70bc9.tar.gz
Delayed commits  allows users to trade off immediate safety for
throughput and reduced storage wear when running multiple
discreet commands.

This feature is currently useful for providing a way to make
t/lei-store-fail.t reliable and for ensuring `lei blob' can
retrieve messages which have not yet been committed.

In the future, it'll also be useful for the FUSE layer to batch
git activity.
Diffstat (limited to 'lib/PublicInbox/LeiStore.pm')
-rw-r--r--lib/PublicInbox/LeiStore.pm6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index 9c07af14..aebb85a9 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -34,6 +34,7 @@ use Sys::Syslog qw(syslog openlog);
 use Errno qw(EEXIST ENOENT);
 use PublicInbox::Syscall qw(rename_noreplace);
 use PublicInbox::LeiStoreErr;
+use PublicInbox::DS qw(add_uniq_timer);
 
 sub new {
         my (undef, $dir, $opt) = @_;
@@ -113,6 +114,11 @@ sub cat_blob {
         $self->{im} ? $self->{im}->cat_blob($oid) : undef;
 }
 
+sub schedule_commit {
+        my ($self, $sec) = @_;
+        add_uniq_timer($self->{priv_eidx}->{topdir}, $sec, \&done, $self);
+}
+
 # follows the stderr file
 sub _tail_err {
         my ($self) = @_;