{"id":30453640,"url":"https://github.com/micqo/gridhouse","last_synced_at":"2026-05-05T08:33:30.014Z","repository":{"id":311069312,"uuid":"1038782022","full_name":"MIcQo/gridhouse","owner":"MIcQo","description":"Gridhouse is simple in-memory database that supports redis protocol (commands)","archived":false,"fork":false,"pushed_at":"2025-08-21T23:47:12.000Z","size":173,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-22T00:31:16.233Z","etag":null,"topics":["cache","caching","database","in-memory-caching","in-memory-database","memory","ranking","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MIcQo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-08-15T20:05:57.000Z","updated_at":"2025-08-21T22:25:19.000Z","dependencies_parsed_at":"2025-08-22T00:31:23.937Z","dependency_job_id":"be6da496-2f89-425f-a11f-cfecba2176a6","html_url":"https://github.com/MIcQo/gridhouse","commit_stats":null,"previous_names":["micqo/gridhouse"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/MIcQo/gridhouse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIcQo%2Fgridhouse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIcQo%2Fgridhouse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIcQo%2Fgridhouse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIcQo%2Fgridhouse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MIcQo","download_url":"https://codeload.github.com/MIcQo/gridhouse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MIcQo%2Fgridhouse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271755394,"owners_count":24815394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"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":["cache","caching","database","in-memory-caching","in-memory-database","memory","ranking","redis"],"created_at":"2025-08-23T16:01:09.651Z","updated_at":"2026-05-05T08:33:30.009Z","avatar_url":"https://github.com/MIcQo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GridHouse\n[![codecov](https://codecov.io/github/MIcQo/gridhouse/graph/badge.svg?token=YBF6MA7FEH)](https://codecov.io/github/MIcQo/gridhouse)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/MIcQo/gridhouse/gotests.yml)\n\nA high-performance Redis-compatible in-memory database written in Go.\n\n## Features\n\n- **Redis Protocol Compatibility**: Full RESP (Redis Serialization Protocol) support\n- **High Performance**: Optimized for maximum throughput (~8.6M ops/sec)\n- **Data Structures**: Strings, Lists, Sets, Hashes, Sorted Sets, and Streams\n- **Persistence**: AOF (Append Only File) and RDB support with configurable sync modes\n- **Replication**: Master-slave replication with PSYNC protocol\n- **Transactions**: Full ACID-compliant transaction support with WATCH/UNWATCH\n- **Statistics**: Comprehensive server statistics and monitoring\n- **Authentication**: Optional password-based authentication\n- **Command Support**: 80+ Redis commands implemented\n\n## Performance\n\nThe Redis Clone achieves exceptional performance through optimizations:\n\n- **SET**: ~8.6M operations/second\n- **GET**: ~6.8M operations/second\n- **INCR**: ~2.3M operations/second\n- **LPUSH/RPUSH**: ~3.7M operations/second\n- **MSET (10 keys)**: ~650K operations/second\n\nThis performance is achieved through:\n- Lock-free command registry with zero-contention lookups\n- Optimized RESP encoding with direct byte writes\n- Connection reuse and buffer optimization\n- Memory-efficient data structures\n- Reduced allocations and GC pressure\n\n## Quick Start\n\n### Building\n\n```bash\n# Build the server\ngo build -o gridhouse main.go\n```\n\n### Running the Server\n\n```bash\n# Start server on default port 6380\n./gridhouse\n\n# Start server on custom port\n./gridhouse --port :6379\n\n# Start with persistence enabled\n./gridhouse --aof --rdb --dir ./data\n\n# Start with authentication\n./gridhouse --requirepass mypassword\n\n# Start as replica\n./gridhouse --slaveof localhost:6379\n\n# Start with custom buffer sizes\n./gridhouse --read-buffer 512000 --write-buffer 512000\n\n# Start with custom log level\n./gridhouse --log-level debug\n```\n\n### Available Command Line Flags\n\n#### Server Configuration\n- `--port`: Server port (default: :6380)\n- `--log-level`: Log level (debug, info, warn, error, fatal) (default: info)\n- `--read-buffer`: Read buffer size in bytes (default: 256KB)\n- `--write-buffer`: Write buffer size in bytes (default: 0)\n\n#### Persistence Configuration\n- `--dir`: Persistence directory (default: ./data)\n- `--aof`: Enable AOF persistence\n- `--aof-sync`: AOF sync mode (always, everysec, no) (default: everysec)\n- `--aof-rewrite`: Enable AOF rewrite (default: true)\n- `--aof-rewrite-growth-threshold`: AOF rewrite growth threshold in bytes (default: 64MB)\n- `--aof-rewrite-min-size`: AOF rewrite minimum size in bytes (default: 32MB)\n- `--aof-rewrite-percentage`: AOF rewrite percentage threshold (default: 100)\n- `--rdb`: Enable RDB persistence\n- `--save-interval`: RDB save interval in seconds (default: 300)\n- `--min-changes`: Minimum changes before RDB save (default: 1)\n\n#### Authentication \u0026 Replication\n- `--requirepass`: Password for AUTH command\n- `--slaveof`: Replicate from master (format: host:port)\n\n### Benchmarking\n\n```bash\n# Run comprehensive benchmarks\n\n# Use redis-benchmark against the server\nredis-benchmark -p 6380 -t get,set,mget,mset,incr,lpush,rpush,lpop,rpop,llen,lrange -q -n 1000000 -P 1000\n```\n\n## Commands Supported\n\n### Basic Commands\n\n- `PING`, `ECHO`, `SET`, `GET`, `DEL`, `EXISTS`\n- `TTL`, `PTTL`, `EXPIRE`, `INCR`, `DECR`\n- `KEYS`, `MSET`, `MGET`, `FLUSHDB`, `DBSIZE`\n- `GETRANGE` (alias `SUBSTR`), `TYPE`\n\n### Data Structure Commands\n\n#### Lists\n- `LPUSH`, `RPUSH`, `LPOP`, `RPOP`, `LLEN`, `LRANGE`, `LINDEX`, `LSET`, `LREM`, `LTRIM`\n\n#### Sets\n- `SADD`, `SREM`, `SISMEMBER`, `SMEMBERS`, `SCARD`, `SPOP`\n\n#### Hashes\n- `HSET`, `HGET`, `HDEL`, `HEXISTS`, `HGETALL`, `HKEYS`, `HVALS`, `HLEN`, `HINCRBY`, `HINCRBYFLOAT`\n\n#### Sorted Sets\n- `ZADD`, `ZREM`, `ZCARD`, `ZSCORE`, `ZRANGE`, `ZPOPMIN`\n\n#### Streams\n- `XADD`, `XLEN`, `XRANGE`, `XDEL`, `XTRIM`, `XREAD`\n\n### Server Commands\n\n- `INFO`, `CONFIG`, `AUTH`, `SAVE`, `BGSAVE`\n- `MEMORY` (USAGE, STATS)\n\n### Transaction Commands\n\n- `MULTI`, `EXEC`, `DISCARD`, `WATCH`, `UNWATCH`\n\n### Replication Commands\n\n- `PSYNC`, `REPLCONF`, `SYNC`, `ROLE`\n\n### Scan Commands\n\n- `SCAN`, `SSCAN`, `HSCAN`\n\n## Architecture\n\n```\ngridhouse/\n├── cmd/                    # Command line tools\n│   ├── benchmark/         # Performance benchmarking tool\n│   └── root.go           # Main server entry point with CLI flags\n├── internal/              # Core implementation\n│   ├── cmd/              # Command handlers and registry\n│   ├── persistence/      # AOF and RDB persistence\n│   ├── repl/             # Replication logic\n│   ├── resp/             # RESP protocol implementation\n│   ├── server/           # Server and connection handling\n│   ├── stats/            # Statistics and monitoring\n│   └── store/            # Data storage and structures\n└── main.go               # Server entry point\n```\n\n## Performance Comparison\n\nComprehensive benchmark results comparing GridHouse against Redis using \n`redis-benchmark -t get,set,mget,mset,incr,lpush,rpush,lpop,rpop,llen,lrange -q -n 1000000 -P 1000`:\n\n| Metric              | GridHouse   | Redis      | Improvement | P50 Latency (GridHouse) | P50 Latency (Redis) |\n|---------------------|-------------|------------|-------------|------------------------|---------------------|\n| **PING_INLINE**     | 7.94M       | 5.32M      | **1.49x**   | 5.479 ms               | 8.103 ms            |\n| **PING_MBULK**      | 8.00M       | 7.58M      | **1.06x**   | 4.695 ms               | 5.559 ms            |\n| **SET**             | 7.87M       | 4.08M      | **1.93x**   | 5.967 ms               | 5.367 ms            |\n| **GET**             | 6.33M       | 5.10M      | **1.24x**   | 5.631 ms               | 5.719 ms            |\n| **INCR**            | 2.23M       | 4.72M      | **0.47x**   | 21.823 ms              | 4.679 ms            |\n| **LPUSH**           | 3.47M       | 3.41M      | **1.02x**   | 13.415 ms              | 8.871 ms            |\n| **RPUSH**           | 3.39M       | 4.61M      | **0.74x**   | 14.167 ms              | 6.351 ms            |\n| **LPOP**            | 3.06M       | 2.95M      | **1.04x**   | 15.887 ms              | 10.447 ms           |\n| **RPOP**            | 3.24M       | 3.72M      | **0.87x**   | 14.983 ms              | 8.063 ms            |\n| **SADD**            | 3.97M       | 4.52M      | **0.88x**   | 12.191 ms              | 4.823 ms            |\n| **HSET**            | 2.82M       | 3.69M      | **0.76x**   | 17.215 ms              | 4.799 ms            |\n| **SPOP**            | 4.88M       | 5.85M      | **0.83x**   | 9.727 ms               | 5.279 ms            |\n| **ZADD**            | 2.79M       | 3.60M      | **0.78x**   | 17.583 ms              | 5.791 ms            |\n| **ZPOPMIN**         | 5.13M       | 6.06M      | **0.85x**   | 9.295 ms               | 4.383 ms            |\n| **MSET (10 keys)**  | 0.57M       | 0.85M      | **0.67x**   | 86.271 ms              | 4.695 ms            |\n| **XADD**            | 2.14M       | 1.93M      | **1.11x**   | 21.999 ms              | 9.823 ms            |\n\n### List Range Performance (LRANGE)\n\n| Range Size          | GridHouse   | Redis      | Improvement | P50 Latency (GridHouse) | P50 Latency (Redis) |\n|---------------------|-------------|------------|-------------|------------------------|---------------------|\n| **LRANGE_100**      | 220.3K      | 238.3K     | **0.92x**   | 12.535 ms              | 7.407 ms            |\n| **LRANGE_300**      | 77.5K       | 57.9K      | **1.34x**   | 26.703 ms              | 139.391 ms          |\n| **LRANGE_500**      | 43.9K       | 34.0K      | **1.29x**   | 33.311 ms              | 237.951 ms          |\n| **LRANGE_600**      | 38.8K       | 26.9K      | **1.44x**   | 34.719 ms              | 279.551 ms          |\n\n### Performance Summary\n\n**GridHouse Strengths:**\n- **SET operations**: 1.93x faster than Redis\n- **GET operations**: 1.24x faster than Redis  \n- **PING operations**: 1.49x faster (inline), 1.06x faster (mbulk)\n- **Large LRANGE operations**: 1.29-1.44x faster with significantly lower latency\n- **XADD (Streams)**: 1.11x faster than Redis\n- **LPOP operations**: 1.04x faster than Redis\n\n**Areas for Improvement:**\n- **INCR operations**: 0.47x (slower due to string parsing overhead)\n- **MSET operations**: 0.67x (slower with higher latency due to batch processing)\n- **Hash operations**: HSET 0.76x (slower due to hash table overhead)\n- **Sorted Set operations**: ZADD 0.78x, ZPOPMIN 0.85x\n- **Set operations**: SADD 0.88x, SPOP 0.83x\n\n**Key Insights:**\n- GridHouse excels at basic SET/GET operations and large list range queries\n- Redis performs better on atomic increment operations, batch multi-key operations, and complex data structures\n- GridHouse shows significantly better latency for large LRANGE operations (300-600 elements)\n- GridHouse has better performance for stream operations (XADD)\n- Redis maintains advantages in hash, set, and sorted set operations\n\n## Development\n\n### Running Tests\n\n```bash\n# Run all tests\nmake test\n\n# Run tests with race detection\nmake test-race\n\n# Run benchmarks\nmake bench\n\n# Run linting\nmake lint\n\n# Tidy dependencies\nmake tidy\n```\n\n### Project Structure\n\n- **Test-Driven Development**: All new features include comprehensive tests\n- **Performance Focus**: Continuous benchmarking and optimization\n- **Redis Compatibility**: Full RESP protocol compliance\n- **Production Ready**: Error handling, logging, and monitoring\n\n## License\n\nThis project is licensed under the GPL-3.0 License (LICENCE).\n\n## Contributing\n\n1. Follow test-driven development (TDD)\n2. Ensure all tests pass\n3. Run benchmarks to verify performance\n4. Follow Go best practices and conventions\n5. Use the optimization workflow: optimize code → run tests → run linter → run redis-benchmark → repeat\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicqo%2Fgridhouse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicqo%2Fgridhouse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicqo%2Fgridhouse/lists"}