new-array creates new array named <array>. An array is a set of key/value pairs, called "elements". A value of an element is obtained based on its key value.
Scope
Note that an array is accessible to the current request only, unless "process-scope" clause is used, in which case all requests served by a process can use it (see do-once for a typical way to create an array with a process scope).
If "process-scope" is used, then <array> will keep its data across all requests in a given process. See write-array for an example of a process-scoped array.
Sizing an array
An array can be of any size, as long as there is enough memory for it. The "hash-size" of an array refers to the size of a hash table used to provide high-performance access to array elements based on a key.
<hash size> is the number of "buckets" used by the hash table underlying the array (it is 10 by default). All array elements with the same hash code are stored in a linked list within the same hash bucket. Greater <hash size> generally means less array elements per bucket and better performance. However, memory usage grows with a bigger hash table, so <hash size> should be balanced based on the program needs.
Gliimly uses high-performing FNV1_a hash algorithm. Each element in a bucket list is lightweight, containing pointers to a key, value and next element in the linked list.
<hash size> must be at least 10; if less, it will be set to 10.
Examples
Create a new array with a hash table with 500 buckets: