Created
April 6, 2016 12:35
-
-
Save J-Gras/061983dac59224a03d3bfad4476a1dd9 to your computer and use it in GitHub Desktop.
Example script to demonstrate the per item expire issue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@load base/frameworks/communication | |
redef exit_only_after_terminate = T; | |
redef table_expire_interval = 1sec; | |
global start_time: time; | |
function time_past(): interval | |
{ | |
return network_time() - start_time; | |
} | |
function expire_nums(tbl: table[count] of string, idx: count): interval | |
{ | |
print fmt("Expired Num: %s --> %s at %s", idx, tbl[idx], time_past()); | |
return 23sec; | |
} | |
global nums: table[count] of string &read_expire=0sec &expire_func=expire_nums; | |
global step: count; | |
event test() | |
{ | |
++step; | |
print fmt("Step: %s at %s", step, time_past()); | |
if ( step == 3 ) | |
{ | |
print fmt("Accessed %s -> %s", 2, nums[2]); | |
print fmt("Accessed %s -> %s", 3, nums[3]); | |
} | |
if ( step < 6 ) | |
schedule 5sec { test() }; | |
else | |
terminate(); | |
} | |
event bro_init() &priority=-10 | |
{ | |
step = 0; | |
start_time = network_time(); | |
nums[0] = "zero"; | |
nums[1] = "one"; | |
nums[2] = "two"; | |
nums[3] = "three"; | |
schedule 0sec { test() }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment