Option ‣ persistent ᴾᴴᴾ - chung-leong/zigar GitHub Wiki

JavaScript | PHP


When enabled, the compiled module will stay in memory even after it is garbage collected.

const std = @import("std");

var counter: usize = 0;

pub fn print() !void {
    std.debug.print("counter = {d}\n", .{counter});
    counter += 1;
}
<?php 

$m = zigar_use(__DIR__ . '/persistent-example-1.zig', persistent: true);
$m->print();
$m = null;
gc_collect_cycles();

$n = zigar_use(__DIR__ . '/persistent-example-1.zig', persistent: true);
$n->print();
counter = 0
counter = 1

In a FastCGI set-up, variables within a module will be preserved between requests.

Default:

false