fix allow 2/more commands on a line
[spider.git] / perl / AnnTalk.pm
index ee7ea51570164916e925f08f34eb24c79dae46ee..71bd272f2736dc6e28642035f92a86311607260c 100644 (file)
@@ -10,10 +10,13 @@ package AnnTalk;
 
 use strict;
 
+use DXVars;
 use DXUtil;
 use DXDebug;
 use DXDupe;
-use DXVars;
+use DXLog;
+use DXLogPrint;
+use Time::HiRes qw(gettimeofday tv_interval);
 
 use vars qw(%dup $duplth $dupage $filterdef);
 
@@ -36,7 +39,26 @@ $filterdef = bless ([
                          ['origin_zone', 'nz', 12],
                          ['by_state', 'nz', 13],
                          ['origin_state', 'nz', 14],
-                        ], 'Filter::Cmd');
+                  ], 'Filter::Cmd');
+
+our $maxcache = 130;
+our @anncache;
+
+sub init
+{
+       my $t0 = [gettimeofday];
+       dbg("AnnTalk: loading up to $maxcache announcements into cache");
+       @anncache = DXLog::search(0, $maxcache, $main::systime, 'ann');
+       shift @anncache while @anncache > $maxcache;
+       my $l = @anncache;
+       dbg("AnnTalk: loaded last $l announcements into cache in " . _diffms($t0) . "mS");
+}
+
+sub add_anncache
+{
+       push @anncache, [ $main::systime, @_ ];
+       shift @anncache while @anncache > $maxcache;
+}
 
 # enter the spot for dup checking and return true if it is already a dup
 sub dup