write-array <array> \ key <key> \ value <value> \ [ status <status> ] \ [ old-value <old value> ]
new-array h write-array h key "mykey" value "some data"
write-array h key "mykey" value "new data" status st old-value od if-true st equal GG_INFO_EXIST @Previous value for this key is <<p-out od>> end-if
%% /arraysrv do-once new-array h hash-size 1024 process-scope end-do-once // Get input parameters get-param op get-param key get-param data if-true op equal "add" // Add data to array, make a copy as input params are request-scoped write-array h key key value data old-value old_data status st if-true st equal GG_INFO_EXIST delete-string old_data end-if @Added [<<p-out key>>] else-if op equal "delete" // Delete data and obtain the value deleted read-array h key (key) value val delete status st if-true st equal GG_ERR_EXIST @Not found [<<p-out key>>] else-if // If found, then delete key and value @Deleted [<<p-out val>>] delete-string val end-if else-if op equal "query" // Query array based on key value read-array h key (key) value val status st if-true st equal GG_ERR_EXIST @Not found, queried [<<p-out key>>] else-if @Value [<<p-out val>>] end-if end-if %%
// Create application sudo mgrg -i -u $(whoami) arr // Make application gg -q // Start application (single process key service) mgrg -w 1 arr
// Add data gg -r --req="/arraysrv/op=add/key=15/data=15" --service --app="/arr" --exec // Query data gg -r --req="/arraysrv/op=query/key=15" --service --app="/arr" --exec // Delete data gg -r --req="/arraysrv/op=delete/key=15" --service --app="/arr" --exec