An in-memory Key-Value database made with Go, for no particular reason other than to learn basic things about the language (really I just thought it would be fun, and it actually was).
go run main.go
The commands below are also recognized even when they are not in uppercase.
HELP
: Display all commandsALL
: Display all entries in the databaseGET <key>
: Get the value of a keyCREATE <key> <value>
: Create a new entry in the databaseDELETE <key>
: Delete an entry from the databaseLEVEL
: Display the current level structureDOWN
: Move down to the next levelAPPLY
: Apply changes to the parent levelDISCARD
: Discard changes and move up to the parent levelEXIT
: Exit the program
A level is the basic data type structure in this database. It essentially defines a map (which is actually where the data is stored), a reference to the parent level, and a depth.
Each level can have its own changes made to the database, and they are only applied/discarded with the commands APPLY
and DISCARD
. Both commands are very similar: they terminate the current level and move up to the parent level. The
difference is that APPLY
applies the changes to the parent level, while DISCARD
discards it.
You can always check where you are with the LEVEL
command.