write rbncache in raw json unless set/deb rbncache
authorDirk Koopman <djk@tobit.co.uk>
Mon, 17 Aug 2020 13:44:10 +0000 (14:44 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Mon, 17 Aug 2020 13:44:10 +0000 (14:44 +0100)
perl/DXUser.pm
perl/Prefix.pm
perl/RBN.pm

index 4994c4e0b0e4c6fbabae178740f4eaf91143e7f5..e5afe25b183e4e6871b4f3bf2e66076463cc15db 100644 (file)
@@ -31,7 +31,7 @@ $dbm = undef;
 $filename = undef;
 $lastoperinterval = 60*24*60*60;
 $lasttime = 0;
-$lrusize = 10000;
+$lrusize = 5000;
 $tooold = 86400 * 365;         # this marks an old user who hasn't given enough info to be useful
 $v3 = 0;
 our $maxconnlist = 3;                  # remember this many connection time (duration) [start, end] pairs
index 659178fbbd09c5b86d3bcd7cc92d370cc9c973f3..2fab0e0b4f9437812f5737a77034c8b815f36955 100644 (file)
@@ -26,7 +26,7 @@ $db = undef;                                  # the DB_File handle
 %prefix_loc = ();                              # the meat of the info
 %pre = ();                                             # the prefix list
 $hits = $misses = $matchtotal = 1;             # cache stats
-$lrusize = 10000;                              # size of prefix LRU cache
+$lrusize = 5000;                               # size of prefix LRU cache
 
 sub init
 {
index 6ec93569b01c0bd837217803c2abf553b2d0fa29..92c66f1a51820431b1c8c3bbda63e6cdacddcafc 100644 (file)
@@ -104,6 +104,7 @@ our $maxdeviants = 5;                       # the number of deviant QRGs to record for skimmer recor
 sub init
 {
        $json = DXJSON->new;
+       $json->canonical(0);
        if (check_cache()) {
                $noinrush = 1;
        } else {
@@ -572,6 +573,8 @@ sub process
                                # we have a candidate, create qualitee value(s);
                                unless (@$cand > CData) {
                                        dbg "RBN: QUEUE key '$sp' MISSING RECORDS, IGNORED" . dd($cand) if isdbg 'rbnqueue';
+                                       delete $spots->{$sp}; # don't remember it either - this means that a spot HAS to come in with sufficient spotters to be processed.
+                                       delete $dxchan->{queue}->{$sp};
                                        next;
                                }
                                dbg "RBN: QUEUE PROCESSING key: '$sp' $now >= $cand->[CTime]" if isdbg 'rbnqueue'; 
@@ -706,8 +709,8 @@ sub process
                                # clear out the data and make this now just "spotted", but no further action required until respot time
                                dbg "RBN: QUEUE key '$sp' cleared" if isdbg 'rbn';
 
-                               delete $spots->{$sp};
                                delete $dxchan->{queue}->{$sp};
+                               delete $spots->{$sp};
 
                                # calculate new sp (which will be 70% likely the same as the old one)
                                # we do this to cope with the fact that the first spotter may well be "wrongly calibrated" giving a qrg that disagrees with the majority.
@@ -793,7 +796,7 @@ sub finish
 sub write_cache
 {
        my $ta = [ gettimeofday ];
-       $json->indent(1) if isdbg 'rbncache';
+       $json->indent(1)->canonical(1) if isdbg 'rbncache';
        my $s = eval {$json->encode($spots)};
        if ($s) {
                my $fh = IO::File->new(">$cachefn") or confess("writing $cachefn $!");
@@ -801,10 +804,12 @@ sub write_cache
                $fh->close;
        } else {
                dbg("RBN:Write_cache error '$@'");
+               return;
        }
-       $json->indent(0);
+       $json->indent(0)->canonical(0);
        my $diff = _diffms($ta);
-       dbg("RBN:WRITE_CACHE time to write: $diff mS");
+       my $size = sprintf('%.3fKB', (length($s) / 1000));
+       dbg("RBN:WRITE_CACHE size: $size time to write: $diff mS");
 }
 
 sub check_cache