# Atomically return and remove the first element of the list. For example if
# the list contains the elements "a","b","c" LPOP will return "a" and the
# list will become "b","c".
#
# If the key does not exist or the list is already empty the special value
# 'nil' is returned.
#
# Return value: bulk reply
defpop_head(key)
timeout_retry(3,3){
write"LPOP #{key}\r\n"
bulk_reply
}
write"LPOP #{key}\r\n"
get_response
end
# RPOP key
# This command works exactly like LPOP, but the last element instead
# of the first element of the list is returned/deleted.
defpop_tail(key)
timeout_retry(3,3){
write"RPOP #{key}\r\n"
bulk_reply
}
end
# LSET key index value
# Time complexity: O(N) (with N being the length of the list)
# Set the list element at index (see LINDEX for information about the index argument) with the new value. Out of range indexes will generate an error. Note that setting the first or last elements of the list is O(1).