Unlike regular variables, RAM variables are never written to disk.
Hence using RAM variables in place of regular variables (especially
within loops) significantly increases execution speed.
Variables that are frequently accessed within for
or where
clauses provide the greatest opportunities for optimization.
To declare and define a RAM variable simply prefix the variable name
with an asterisk (*
) when the variable is declared/initialized.
To delete a RAM variables (and recover their memory) use the
ram_delete()
method.
To write a RAM variable to disk (like a regular variable) use
ram_write()
.
*temp[$time,$lat,lon]=10.0; // Cast *temp_avg=temp.avg($time); // Regular assign temp.ram_delete(); // Delete RAM variable temp_avg.ram_write(); // Write Variable to output // Create and increment a RAM variable from "one" in Input *one++; // Create RAM variables from the variables three and four in Input. // Multiply three by 10 and add it to four. *four+=*three*=10; // three=30, four=34