{"id":20115660,"url":"https://github.com/raadiah/redis","last_synced_at":"2026-02-06T06:01:32.312Z","repository":{"id":248798627,"uuid":"287209636","full_name":"Raadiah/Redis","owner":"Raadiah","description":"An overview of Redis","archived":false,"fork":false,"pushed_at":"2020-08-15T03:14:40.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-23T00:44:11.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/Raadiah.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}},"created_at":"2020-08-13T07:21:08.000Z","updated_at":"2020-08-15T03:14:42.000Z","dependencies_parsed_at":"2024-07-17T06:52:24.901Z","dependency_job_id":null,"html_url":"https://github.com/Raadiah/Redis","commit_stats":null,"previous_names":["raadiah/redis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Raadiah/Redis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raadiah%2FRedis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raadiah%2FRedis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raadiah%2FRedis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raadiah%2FRedis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Raadiah","download_url":"https://codeload.github.com/Raadiah/Redis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raadiah%2FRedis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29153129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-11-13T18:36:07.959Z","updated_at":"2026-02-06T06:01:32.239Z","avatar_url":"https://github.com/Raadiah.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redis\nThis is an open source documentation and work done as an assignment under **Brilliant Cloud Research Team**. The goal of this sub-project is:\n* Understanding core concepts of redis\n* Implement a Redis cluster that will hold data of millions\n* Document all work\n\nSo, let's start with Redis! \n\n## A simple illustration of Redis\nRedis is an in-memory data structure store. By in-memory we mean that Redis stays on main memory, that is RAM, which makes it super fast also. It can store several kind of data structures. These are: strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams.\n\nNow, here is the interesting part of Redis. It is not a relational database like MySQL or PostgreSQL etc. We do not save data in form of tables here. So how do we store the data? Data are stored in form of key-value pair. Here, values can be retrieved using the key, but the vice-versa is not possible. So,\n\n```\nSET KEY VALUE\n\n```\n\nsets value to a key. And,\n\n```\nGET KEY\n\n```\n\ngets value from a key!\n\n#### Now, where is Redis used?\n\nRedis has three kind of application. It can be used as:\n\n* Database\n* Cache\n* Message broker\n\n## Example of use of Redis as a database\n\nWe have seen before that Redis stores value as a key-value pair. To understand, how Redis can be used as a database, we must look at some instructions and the data structures supported by Redis. Note that, not all are data structures are covered here.\n\n### String\n\nThey are stored as key value pair as shown above.\n\n```\nSET name \"Peter\"\nGET name =\u003e Peter\n\n```\n\nAn interesting operation is `INCR` which parses the string value as an integer and increases it by 1. The operation is atomic.\n\n### List\n\nThese are linked lists. You can push element to a list using ```LPUSH``` which pushes to the left of the list, or ```RPUSH``` which pushes to the right of the string.\n\n```\nLPUSH sample_list a\nRPUSH sample_list b\nLPUSH sample_list c\n\n```\n\nThe resultant list of the above command will be a list like \n\n```\n'c', 'a', 'b'\n```\nNow, range query of the list is possible. For example\n\n```\nLRANGE sample_list 0 1 =\u003e c, a\nLRANGE sample_list 0 -1 =\u003e c, a, b\n```\n###### NOTES\n1. Sample_list is the key here, and the whole list is the value\n1. The index is zero based. \n1. In second command, a negative value is used. It has another meaning. -1 means last element. -2 means second last element and so on. So, 0 -1 means all elements from range 0 to last element.\n1. We do not have to create empty list or remove a list when it is empty. It is the responsibility of Redis to remove the key when it is empty. In the example\n\n### Set\n\nThese are unordered set. To add an element to the set:\n\n```\nSADD myset a\nSADD myset b\nSADD myset foo\nSADD myset bar\nSCARD myset =\u003e 4\nSMEMBERS myset =\u003e bar,a,foo,b\n```\n\n### Redis Hashes\n\nThey  are field-value pair data structure. To set a  hash:\n\n```\nHMSET myuser name Peter sur_name Pan city Neverland\nHGET myuser city =\u003e Neverland\n```\nIn the [official documentation](https://redis.io/topics/data-types-intro) it says, *While hashes are handy to represent objects, actually the number of fields you can put inside a hash has no practical limits (other than available memory), so you can use hashes in many different ways inside your application.*\n\n### Creating a database\n\nNow, suppose you need a database of the schema: person. The description of the schema is:\n\n  Person Schema | \n  ---------------------------------------------------------- | \n  Person Id | \n  National Id | \n  Name | \n\n\n\nHere, Person Id is auto increment. National Id is saved for unique person.\n\nSo you can use the following structure to create the database. Firstly, we initialize Person_id with 0.\n\n``` \nSET Person_id 0\n```\n\nWhen a new person registers:\n\n```\nINCREMENT Person_id =\u003e 1\nHMSET user:1 National_Id 6fYtthat Name Peter\nHSET users 6fYtthat 1\n\n```\nHere, every time a new person is registered the *Person_id* is increased by 1. Then at the *user:person_id* the information of the person is saved. To keep a set of all the users a hash *users* is created which is populated with *National_Id* (which is \"6fYtthat\") refering to the *Person_id*. \n\nThis is a common design pattern using key value data structure. That is how you make a database! Easy and fun, right?\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraadiah%2Fredis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraadiah%2Fredis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraadiah%2Fredis/lists"}