https://github.com/ViniciusCestarii/ElixKey
CLI and key-value db made only with Elixir and its native libraries
https://github.com/ViniciusCestarii/ElixKey
cli db elixir
Last synced: 2 months ago
JSON representation
CLI and key-value db made only with Elixir and its native libraries
- Host: GitHub
- URL: https://github.com/ViniciusCestarii/ElixKey
- Owner: ViniciusCestarii
- Created: 2024-09-04T12:37:35.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-11-05T16:42:51.000Z (6 months ago)
- Last Synced: 2025-01-04T14:27:43.441Z (4 months ago)
- Topics: cli, db, elixir
- Language: Elixir
- Homepage:
- Size: 7.03 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ElixKey: Cumbuca desafio Elixir DB e CLI
[](https://github.com/ViniciusCestarii/cumbuca-desafio/actions/workflows/test.yml)
Solução do [desafio proposto pela Cumbuca](https://github.com/appcumbuca/desafios/blob/master/desafio-back-end-pleno.md)
## Descrição
O desafio é desenvolver uma interface de linha de comando (CLI) e um banco de dados key-value utilizando exclusivamente a linguagem Elixir e suas bibliotecas nativas.
## Solução
A CLI foi implementada utilizando a biblioteca nativa IO do Elixir, onde o usuário pode interagir com o banco de dados key-value através de comandos como `SET`, `GET`, `BEGIN`, `ROLLBACK` e `COMMIT`.
O banco de dados key-value foi implementado com persistência, armazenando os dados em um arquivo binário. As transações e o estado da aplicação são mantidos em memória utilizando estruturas `Map`.
Adicionados novos comandos: `EXIT`, `EXISTS` e `DELETE`.
## Commands
### `SET `
Sets the value associated with the specified key.returns: TRUE or FALSE if the key already exists and the value.
### `GET `
Gets the value associated with the specified key.
returns: The value associated with the key or NIL if the key does not exist.
### `DELETE `
Deletes the value associated with the specified key.
returns: TRUE or FALSE if the key exists.
### `EXISTS `
Checks if the key exists.
returns: TRUE or FALSE if the key exists.
### `BEGIN`
Starts a new transaction.
returns: nesting level of transactions.
### `ROLLBACK`
Rolls back the current transaction.
returns: nesting level of transactions.
### `COMMIT`
Commits the current transaction.
returns: nesting level of transactions.
### `EXIT`
Exits the CLI.
returns: Goodbye message.
## Pré-requisitos
Primeiro, será necessário [instalar o Elixir](https://elixir-lang.org/install.html)
em versão igual ou superior a 1.16.
Com o Elixir instalado, você terá a ferramenta de build `mix`.Para buildar o projeto, use o comando `mix escript.build` nesta pasta.
Isso irá gerar um binário com o mesmo nome do projeto na pasta.
Executando o binário, sua CLI será executada.Executando binário no Linux:
```bash
./elix_key
```Executando binário no Windows:
```bash
escript elix_key
```## Running with Docker
Build the image:
```bash
docker build -t elix_key .
```Run the container:
```bash
docker run -it --rm elix_key
```## Running tests with Docker
Build the image:```bash
docker build -t elix_key .
```Run the tests:
```bash
docker run --rm elix_key mix test
```