{"id":22957373,"url":"https://github.com/biohacker0/crowredis","last_synced_at":"2025-08-13T03:33:09.291Z","repository":{"id":200992940,"uuid":"703521307","full_name":"biohacker0/crowRedis","owner":"biohacker0","description":"Built Simple memory datastore like redis to learn how it works internally and how databases are built , it has set,get, transactions (multi/exec ),persistence(snapshots, AOF) , concurrency support for all things and concurrent transactions and Data Replication","archived":false,"fork":false,"pushed_at":"2023-10-30T23:06:15.000Z","size":89,"stargazers_count":30,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T15:56:34.973Z","etag":null,"topics":["data-store"],"latest_commit_sha":null,"homepage":"","language":"Python","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/biohacker0.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}},"created_at":"2023-10-11T11:57:02.000Z","updated_at":"2025-02-27T21:24:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"f83b9067-d3a7-41bb-9244-f954e95487a5","html_url":"https://github.com/biohacker0/crowRedis","commit_stats":null,"previous_names":["biohacker0/crowredis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/biohacker0/crowRedis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FcrowRedis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FcrowRedis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FcrowRedis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FcrowRedis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biohacker0","download_url":"https://codeload.github.com/biohacker0/crowRedis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohacker0%2FcrowRedis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270175827,"owners_count":24540094,"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-13T02:00:09.904Z","response_time":66,"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":["data-store"],"created_at":"2024-12-14T17:16:21.843Z","updated_at":"2025-08-13T03:33:08.971Z","avatar_url":"https://github.com/biohacker0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crowRedis\n- I built my own small simple in-memory datastore like redis to learn how it works internally and how databases are built , it has set,get,del, transactions (multi/exec ),persistence(snapshots, AOF) , concurrency support for all things and concurrent transactions.\n\n- For Data replication, check out dataReplication-1 branch\n\n# [Blog-1](https://corvus-ikshana.hashnode.dev/building-a-simple-redis-like-data-store-crowredis-in-python)\n# [Blog-2](https://corvus-ikshana.hashnode.dev/crowredis-data-replication-delving-into-distributed-systems)\n\n## Features\n\n- **Key-Value Storage**: Store and retrieve data as key-value pairs in the Redis server.\n\n- **Data Manipulation**: Supports common Redis commands such as `SET`, `GET`, and `DEL` for data manipulation.\n\n- **TTL (Time to Live)**: Set TTL for keys to automatically expire and remove them from the database after a specified time.\n\n- **Atomic Increment and Decrement**: Use `INCR` and `DECR` to increment and decrement integer values associated with keys.\n\n- **Transaction Support**: Execute multi-step transactions using the `MULTI`, `EXEC`, and `DISCARD` commands.\n\n- **Append-Only File (AOF) Logging**: Enable AOF for command logging and recovery. Recover data from the AOF file when the server restarts.\n\n\n```\nSET mykey myvalue             # Set a key-value pair\nGET mykey                    # Retrieve the value for a key\nINCR mycounter               # Increment a counter\nDECR mycounter               # Decrement a counter\nEXPIRE mykey 60              # Set a TTL for a key\nMULTI                        # Start a transaction\nSET key1 value1              # Add commands to the transaction\nSET key2 value2\nEXEC                         # Execute the transaction\n```\n\n\n## Prerequisites\n\nBefore you can run crowRedis and the client, make sure you have the following prerequisites installed on your system:\n\n- Python (3.x recommended)\n- Socket library (should be included with Python\n\n# How To use this:\n -  After cloning , run the crowRedis.py file , its the server that will listen to all your requests.\n -  Then run the client.py file , its the client where you can write your queries like ex: set name myname , get name , del name.\n -  rest scripts are for benchmarks and logs and snapshot file will be created automatically\n\n  ## Benchmark Test\n I compared crowRedis and postgressSQL and real Redis again each other for some parameters on same hardware to see what are the test results :\n- plz don't that this seriously, cause I am comparing a relational database with a memory database, but I wanted to see how much is a RAM-based database faster a disk-based one.\n- Also, real Redis use a very complex mechanism for set,get,del of data and, mine is way too simplistic, that's why it's doing so fast operations.\n- I am also learning things and might do some stupid comparisons so plz forgive me , I will learn what I don't know and improve ✌️\n\n| Benchmark | Time taken (seconds) | Database |\n|-----------|----------------------|----------|\n| INSERT    | 0.1802               | postgresSQL |\n| UPDATE    | 1.6753               | postgresSQL |\n| DELETE    | 0.2250               | postgresSQL |\n| TRANSACTIONS | 0.0680            | postgresSQL |\n| Throughput | 1470.95 transactions per second | postgresSQL |\n| Average response time | 0.0007 seconds | postgresSQL |\n\n\n\n| **Metric**            | **Value**                          | **Database** |\n|-----------------------|------------------------------------|--------------|\n| Total time taken      | 0.021941661834716797 seconds       | crowRedis        |\n| Throughput            | 4557.54 transactions per second    | crowRedis        |\n| Average response time | 0.0002 seconds                     | crowRedis        |\n| Benchmark SET         | 1000 requests in 0.4349 seconds    | crowRedis        |\n| Benchmark GET         | 1000 requests in 0.0271 seconds    | crowRedis        |\n| Benchmark DEL         | 1000 requests in 0.0322 seconds    | crowRedis        |\n\n\n\n| **Metric**            | **Value**                          | Database |\n|-----------------------|------------------------------------| ---------|\n| Total time taken      | 0.016948461532592773 seconds       | Redis  |\n| Throughput            | 5900.24 transactions per second    | Redis  |\n| Average response time | 0.0002 seconds                     | Redis  |\n| Benchmark SET         | 1000 requests in 0.0280 seconds    | Redis  |\n| Benchmark GET         | 1000 requests in 0.0320 seconds    | Redis  |\n| Benchmark DEL         | 1000 requests in 0.0315 seconds    | Redis  |\n\n\n# Using the Redis Client(client.py)\n\n\nSET key value - Set the value of a key.  \nExample:  \n```redis\nSET mykey Hello\n```\n\nGET key - Get the value associated with a key.  \nExample:  \n```redis\nGET mykey\n```\n\nSetting TTL (Time to Live) for a Key.\n```redis\nSET mykey 42 EX 60\n```\n\nUsing INCR and DECR\n```redis\n# Increment a counter\nINCR page_views\n\n# Decrement a counter\nDECR stock_count\n\n```\n\n\nDEL key - Delete a key and its associated value.  \nExample:  \n```redis\nDEL mykey\n```\n\nSAVE - Save data to a snapshot file.  \nExample:  \n```redis\nSAVE\n```\n\nMULTI - Start a transaction block.  \nExample:  \n```redis\nMULTI\n```\n\nEXEC - Execute the commands in a transaction.  \nExample:  \n```redis\nMULTI\nSET key1 value1\nSET key2 value2\nEXEC\n```\n\nDISCARD - Discard the commands in a transaction.  \nExample:  \n```redis\nMULTI\nSET key1 value1\nDISCARD\n```\n\nLPUSH key value1 [value2 ...] - Insert one or more values at the beginning of a list.  \nExample:  \n```redis\nLPUSH mylist item1\nLPUSH mylist item2 item3\n```\n\nRPUSH key value1 [value2 ...] - Append one or more values to the end of a list.  \nExample:  \n```redis\nRPUSH mylist item4\nRPUSH mylist item5 item6\n```\n\nLPOP key - Remove and return the first element from a list.  \nExample:  \n```redis\nLPOP mylist\n```\n\nRPOP key - Remove and return the last element from a list.  \nExample:  \n```redis\nRPOP mylist\n```\n\nLRANGE key start stop - Get a range of elements from a list.  \nExample:  \n```redis\nLRANGE mylist 0 2\n```\n```\n\nOnce you have the client running, you can interact with the crowRedis server. Here's how the client works:\n\nTo send a Redis command, enter it at the prompt and press Enter.\nTo exit the client, type 'exit' and press Enter.\nTransaction Support\nYou can also work with transactions using the following commands:\n\nTo start a transaction, enter 'MULTI'.\nEnter the transaction commands one by one.\nTo execute the transaction, enter 'EXEC'.\nTo discard the transaction, enter 'DISCARD'.\nThe client will send these commands to the server and display the responses.\n\nData Persistence\ncrowRedis supports data persistence through snapshot files and an append-only file (AOF). It automatically saves data to a snapshot file at regular intervals and recovers data from the AOF file upon server startup.\n\nTransactions\ncrowRedis allows you to group multiple commands into a transaction using the MULTI command. You can add commands to the transaction and then use EXEC to execute them or DISCARD to cancel the transaction.\n\nList Operations\ncrowRedis supports list operations, including LPUSH, RPUSH, LPOP, RPOP, and LRANGE, allowing you to manipulate lists stored as values in the data store.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiohacker0%2Fcrowredis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiohacker0%2Fcrowredis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiohacker0%2Fcrowredis/lists"}