%% /indexsrv public
do-once
new-index t process-scope
end-do-once
get-param op
get-param key
get-param data
if-true op equal "add"
write-index t key (key) value data status st
if-true st equal GG_OKAY
@Added [<<p-out key>>]
else-if
@Key exists
end-if
else-if op equal "delete"
delete-index t key (key) value val status st
if-true st equal GG_ERR_EXIST
@Not found [<<p-out key>>]
else-if
@Deleted [<<p-out val>>]
delete-string val
end-if
else-if op equal "query"
read-index t equal (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
%%
Copied!
# Add key=1 and data=d1
$ gg -r --req="/indexsrv/op=add/key=1/data=d1" --service --exec --silent-header
Added [1]
# Add key=2 and data=d2
$ gg -r --req="/indexsrv/op=add/key=2/data=d2" --service --exec --silent-header
Added [2]
# Query key=1
$ gg -r --req="/indexsrv/op=query/key=1" --service --exec --silent-header
Value [d1]
# Query key=2
i$ gg -r --req="/indexsrv/op=query/key=2" --service --exec --silent-header
Value [d2]
# Delete key=2
$ gg -r --req="/indexsrv/op=delete/key=2" --service --exec --silent-header
Deleted [d2]
# Query key=2
$ gg -r --req="/indexsrv/op=query/key=2" --service --exec --silent-header
Not found, queried [2]
Copied!