File Server in go
- Write: create a file, or update the file’s contents if it already exists.
Usage : write <filename> <numbytes> [<exptime>]\r\n<content bytes>\r\n
Response : OK <version>\r\n - Read: Given a filename, retrieve the corresponding file.
Usage: read <filename>\r\n
Response : CONTENTS <version> <numbytes> <exptime>\r\n <content bytes>\r\n - Compare and swap. This replaces the old file contents with the new content
provided the version is still the same.
Usage: cas <filename> <version> <numbytes> [<exptime>]\r\n <content bytes>\r\n
Response : OK <version>\r\n - Delete file
Usage: delete <filename>\r\n
Response: OK\r\n
- ERR_VERSION\r\n (the contents were not updated because of a version mismatch)
- ERR_FILE_NOT_FOUND\r\n (the filename doesn’t exist)
- ERR_CMD_ERR\r\n (the command is not formatted correctly)
- ERR_INTERNAL\r\n (any other error you wish to report that is not covered by the rest)
- If the power fails, then all the data is lost