%% /hashsrv
out-header default
do-once
new-hash define h size 1024 process-scope
end-do-once
task-param op
input-param key
input-param data
if-task "add"
copy-string key to define c_key
copy-string data to define c_data
write-hash h key c_key value c_data old-value define old_data old-key define old_key status define st
if (st == VV_ERR_EXIST) {
delete-mem old_key
delete-mem old_data
}
@Added [<<p-out key>>]
else-task "delete"
read-hash h key (key) value define val old-key define okey delete status define st
if (st == VV_ERR_EXIST) {
@Not found [<<p-out key>>]
} else {
@Deleted [<<p-out val>>]
delete-mem val
delete-mem okey
}
else-task "query"
read-hash h key (key) value define val status define st
if (st == VV_ERR_EXIST) {
@Not found, queried [<<p-out key>>]
} else {
@Value [<<p-out val>>]
}
end-task
%%
You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a dofollow link back to this page - see full license at
CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind. Icons from
table-icons.io copyright Paweł Kuna, licensed under
MIT license.