1N/A# Check ->defer and ->flush methods 1N/A# This is the old version, which you used in the past when 1N/A# there was a defer buffer separate from the read cache. 1N/A# There isn't any longer. 1N/Aprint "ok $N\n"; $N++;
1N/Aprint $o ?
"ok $N\n" :
"not ok $N\n";
1N/A# (3-6) Deferred storage 1N/A# (9-12) Deferred writing disabled? 1N/A# (13-18) Now let's try two batches of records 1N/A# (19-22) Deferred writing past the end of the file 1N/A# (23-26) Now two long batches 1N/A# (27-30) Now let's make sure that discarded writes are really discarded 1N/A# We have a 2Mib buffer here, so we can be sure that we aren't accidentally 1N/A $a[$_] = "discarded$_"; 1N/A################################################################ 1N/A# Now we're going to test the results of a small memory limit 1N/A$data =
join "$:",
map("record$_", 0..7),
"";
# records are 8 or 9 bytes long 1N/A# Limit cache+buffer size to 47 bytes 1N/A# -- that's enough space for 5 records, but not 6, on both \n and \r\n systems 1N/A# -- that's enough space for 2 records, but not 3, on both \n and \r\n systems 1N/Aprint $o ?
"ok $N\n" :
"not ok $N\n";
1N/A# (31-32) Fill up the read cache 1N/A# the cache now contains records 3,4,5,6,7. 1N/A# (33-44) See if overloading the defer starts by flushing the read cache 1N/A# and then flushes out the defer 1N/A$a[
0] =
"recordA";
# That should flush record 3 from the cache 1N/A {0 => "recordA$:"});
1N/A$a[
1] =
"recordB";
# That should flush record 4 from the cache 1N/A$a[
2] =
"recordC";
# That should flush the whole darn defer 1N/A# This shouldn't change the cache contents 1N/A$a[
3] =
"recordD";
# even though we flushed, deferring is STILL ENABLED 1N/A {3 => "recordD$:"});
1N/A# Check readcache-deferbuffer interactions 1N/A# (45-47) This should remove outdated data from the read cache 1N/A {3 => "recordD$:", 5 => "recordE$:"});
1N/A# (48-51) This should read back out of the defer buffer 1N/A# without adding anything to the read cache 1N/Aprint $z
eq "recordE" ?
"ok $N\n" :
"not ok $N\n"; $N++;
1N/A {3 => "recordD$:", 5 => "recordE$:"});
1N/A# (52-55) This should repopulate the read cache with a new record 1N/Aprint $z
eq "recordA" ?
"ok $N\n" :
"not ok $N\n"; $N++;
1N/A {3 => "recordD$:", 5 => "recordE$:"});
1N/A# (56-59) This should flush the LRU record from the read cache 1N/Aprint $z
eq "record4" ?
"ok $N\n" :
"not ok $N\n"; $N++;
1N/A {3 => "recordD$:", 5 => "recordE$:"});
1N/A# (60-63) This should FLUSH the deferred buffer 1N/Aprint $z
eq "recordD" ?
"ok $N\n" :
"not ok $N\n"; $N++;
1N/Acheck_caches({7 => "record7$:", 0 => "recordA$:", 4 => "record4$:", 3 => "recordZ$:"}, 1N/A# (64-66) We should STILL be in deferred writing mode 1N/Acheck_caches({7 => "record7$:", 0 => "recordA$:", 4 => "record4$:", 3 => "recordZ$:"}, 1N/A {5 => "recordX$:"});
1N/A# Fill up the defer buffer again 1N/A# (67-69) This should OVERWRITE the existing deferred record 1N/A# and NOT flush the buffer 1N/A {5 => "recordQ$:", 4 => "recordP$:"});
1N/A# (70-72) Discard should just dump the whole deferbuffer 1N/A# (73-75) NOW we are out of deferred writing mode 1N/A# (76-79) Last call--untying the array should flush the deferbuffer 1N/A {0 => "flushed$:" });
1N/A# (79) We can't use check_contents any more, because the object is dead 1N/A{ local $/ ; $z = <F> } 1N/A################################################################ 1N/A# my $integrity = $o->_check_integrity($file, $ENV{INTEGRITY}); 1N/A# print $integrity ? "ok $N\n" : "not ok $N\n"; 1N/A # Copy the contents of the cache into a regular hash 1N/A print $good ? "ok $N\n" : "not ok $N\n"; 1N/A } elsif ($b->{$k} ne $a->{$k}) {