{"id":50345062,"url":"https://github.com/carvalhocaio/redis-like-golang","last_synced_at":"2026-05-29T19:30:25.631Z","repository":{"id":353331112,"uuid":"1213496302","full_name":"carvalhocaio/redis-like-golang","owner":"carvalhocaio","description":"A lightweight Redis-like key-value server built in Go. It exposes a simple TCP interface, supports TTL-based expiration, and can optionally persist write operations using an append-only file (AOF).","archived":false,"fork":false,"pushed_at":"2026-04-23T11:57:31.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-23T13:31:21.515Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carvalhocaio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-17T12:51:07.000Z","updated_at":"2026-04-23T11:57:34.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/carvalhocaio/redis-like-golang","commit_stats":null,"previous_names":["carvalhocaio/redis-like-golang"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/carvalhocaio/redis-like-golang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvalhocaio%2Fredis-like-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvalhocaio%2Fredis-like-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvalhocaio%2Fredis-like-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvalhocaio%2Fredis-like-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carvalhocaio","download_url":"https://codeload.github.com/carvalhocaio/redis-like-golang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvalhocaio%2Fredis-like-golang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33668185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-29T19:30:25.045Z","updated_at":"2026-05-29T19:30:25.622Z","avatar_url":"https://github.com/carvalhocaio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redis-Like Golang\n\nA lightweight Redis-like key-value server built in Go. It exposes a simple TCP interface, supports TTL-based expiration, and can optionally persist write operations using an append-only file (AOF).\n\n## Overview\n\nThis project is a learning-oriented Redis-inspired server that focuses on core data operations and clean architecture principles. It includes a server entrypoint, a minimal CLI client, in-memory storage with expiration handling, and optional AOF replay on startup.\n\n## Features\n\n- In-memory key-value store with thread-safe access\n- Core commands: `SET`, `GET`, `DEL`\n- Expiration commands: `EXPIRE`, `TTL`, `PERSIST`\n- Utility commands: `KEYS`, `EXISTS`, `PING`, `INFO`, `QUIT`\n- Wildcard key matching for `KEYS` (`*` and `?` patterns)\n- Optional AOF persistence and replay (`-aof` flag)\n- Graceful server shutdown support\n- Unit and integration test coverage\n\n## Tech Stack\n\n- **Language:** Go (`go 1.26.1` in `go.mod`)\n- **Networking:** Go standard library (`net`, `bufio`)\n- **Concurrency:** Goroutines, `sync.RWMutex`, `sync/atomic`\n- **Dependency Injection:** [Google Wire](https://github.com/google/wire)\n- **Testing:** Go `testing` package (unit + integration tests)\n\n## Architecture\n\nThe codebase follows a layered structure inspired by clean architecture:\n\n- `internal/domain`: Core entities, command types, and repository contracts\n- `internal/usecase`: Command execution and stats logic\n- `internal/adapter`: TCP handler and protocol parser\n- `internal/infrastructure`: Storage and persistence implementations\n- `internal/container`: Dependency wiring (Wire)\n- `cmd/server`: Server application entrypoint\n- `cmd/client`: Simple CLI client for manual testing\n\n## Prerequisites\n\n- Go 1.26+ installed\n\n## Getting Started\n\n### 1. Run the server\n\n```bash\ngo run ./cmd/server\n```\n\nServer flags:\n\n- `-port` (default: `6379`)\n- `-aof` (default: `false`)\n\nExample with AOF enabled:\n\n```bash\ngo run ./cmd/server -port 6379 -aof\n```\n\n### 2. Connect with the CLI client\n\nIn another terminal:\n\n```bash\ngo run ./cmd/client localhost:6379\n```\n\n## Quick Command Demo\n\nAfter connecting with the client:\n\n```text\nSET user:1 Alice\nGET user:1\nEXPIRE user:1 30\nTTL user:1\nEXISTS user:1 user:2\nKEYS user:*\nPING hello\nINFO\nQUIT\n```\n\n## Supported Commands\n\n| Command | Example | Behavior |\n| --- | --- | --- |\n| `SET` | `SET key value` | Sets a key to a value |\n| `GET` | `GET key` | Returns the value or `nil` |\n| `DEL` | `DEL key1 key2` | Deletes keys and returns removed count |\n| `EXPIRE` | `EXPIRE key 60` | Sets expiration in seconds |\n| `TTL` | `TTL key` | Returns remaining seconds or `-1` |\n| `PERSIST` | `PERSIST key` | Removes key expiration |\n| `KEYS` | `KEYS user:*` | Returns matching keys |\n| `EXISTS` | `EXISTS key1 key2` | Returns how many keys exist |\n| `PING` | `PING` or `PING hello` | Returns `PONG` or custom message |\n| `INFO` | `INFO` | Returns server stats summary |\n| `QUIT` | `QUIT` | Closes the client connection |\n\n## Persistence (AOF)\n\nWhen `-aof` is enabled:\n\n- Write commands are appended to an AOF file (`data.aof`)\n- The server replays the file on startup to recover state\n\nThis persistence model is intentionally simple and focused on core recovery behavior.\n\n## Running Tests\n\nRun all tests:\n\n```bash\ngo test ./...\n```\n\nThe repository includes:\n\n- Unit tests for protocol parsing and storage behavior\n- Integration tests for end-to-end TCP command flows\n\n## Current Scope and Notes\n\n- Uses a plain text, line-based protocol (not full RESP compatibility)\n- Intended as a Redis-like educational project, not a production Redis replacement\n- Focused on string values and core command semantics\n\n## Possible Next Improvements\n\n- RESP protocol support for better client compatibility\n- Additional data types (lists, sets, hashes)\n- Authentication and access control\n- Replication and clustering\n- Richer metrics and observability\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarvalhocaio%2Fredis-like-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarvalhocaio%2Fredis-like-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarvalhocaio%2Fredis-like-golang/lists"}