{"id":18623940,"url":"https://github.com/lloydzhou/redisim","last_synced_at":"2025-08-16T23:11:49.572Z","repository":{"id":61846117,"uuid":"550383007","full_name":"lloydzhou/redisim","owner":"lloydzhou","description":"redis im server","archived":false,"fork":false,"pushed_at":"2024-03-28T15:14:36.000Z","size":257,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-13T12:19:04.644Z","etag":null,"topics":["chat","chat-application","chatroom","im","redis","redis-module","redis-modules","stream"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lloydzhou.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}},"created_at":"2022-10-12T17:08:36.000Z","updated_at":"2024-01-25T05:00:39.000Z","dependencies_parsed_at":"2024-04-01T03:45:20.435Z","dependency_job_id":null,"html_url":"https://github.com/lloydzhou/redisim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lloydzhou/redisim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Fredisim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Fredisim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Fredisim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Fredisim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lloydzhou","download_url":"https://codeload.github.com/lloydzhou/redisim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Fredisim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270781393,"owners_count":24643820,"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-16T02:00:11.002Z","response_time":91,"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":["chat","chat-application","chatroom","im","redis","redis-module","redis-modules","stream"],"created_at":"2024-11-07T04:26:45.758Z","updated_at":"2025-08-16T23:11:49.552Z","avatar_url":"https://github.com/lloydzhou.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# 使用redis stream实现im\n\n## redis key\n\n1. `u:\u003cuid\u003e` hash, 存放用户信息，例如name/avatar等\n2. `s:\u003cuid\u003e` stream, 这个队列用于接收/发送用户消息\n3. `c:\u003cuid\u003e` sorted set, 用于存放用户联系人（包括群组）\n4. `gm:\u003cgid\u003e` set, 用于存放群用户id\n5. `gs:\u003cgid\u003e` stream, 用于接收/发送群消息\n6. `gi:\u003cgid\u003e` hash, 存放群信息，例如name，还有一些配置信息（例如加群是否需要验证？）\n\n## redis module\n\u003e redis module实现IM\n\n### IM.RECIVE\n\u003e IM.RECIVE [uid] BLOCK [ms] COUNT [count] START [start]  \n\u003e 获取历史消息，以及监听新的消息\n\n### IM.MESSAGE\n\u003e IM.RECIVE [GROUP | USER] [uid | gid] [mid]  \n\u003e 获取单条消息\n\n### IM.SEND\n\u003e IM.SEND [uid] [tuid] [field value] [field value ... ]  \n\u003e 发送单聊消息\n\n### IM.GSEND\n\u003e IM.GSEND [uid] [gid] [field value] [field value ... ]  \n\u003e 发送群聊消息\n\n### IM.USER\n\u003e IM.USER  [uid]  \n\u003e (get user info)  获取用户信息  \n\u003e IM.USER  [uid] [field value] [field value ... ]  \n\u003e (create user or update user info)\n\n### IM.GROUP\n\u003e IM.GROUP [gid]  \n\u003e (get group info)  \n\u003e IM.GROUP [gid] [uid] [field value] [field value ... ]  \n\u003e (create group or update group info)\n\n### IM.LINK\n\u003e IM.LINK [uid] [tuid]  \n\u003e (add to user contact list)\n\n### IM.UNLINK\n\u003e IM.UNLINK [uid] [tuid]  \n\u003e (remove from user contact list)\n\n### IM.JOIN\n\u003e IM.LINK [uid] [gid]  \n\u003e (add to user group)\n\n### IM.QUIT\n\u003e IM.QUIT [uid] [gid]  \n\u003e (remove from user group)\n\n## GUI\n1. using tornado WebSocketHandler to create websocket.\n2. using svelte create simple ui to send message (using localStorage to save message)\n\n\n## docker\n\n```\ndocker run --rm --name=redisim -p 8888:8888 lloydzhou/redisim\n```\n\n# python sdk\n```\npip install redisim\n```\n## demo\n```\nimport asyncio\nimport redis.asyncio as redis\nimport redisim\n\nasync def main():\n    client = redis.Redis(decode_responses=True)\n    res = await client.im().recive(user_id, **kwargs)\n    print(res)\n\nasyncio.run(main())\n```\n\n## lua script version\n```\nim = client.im(module=False)\n```\n\n## apache/kvrocks\n\nusing lua script version with apache/kvrocks\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flloydzhou%2Fredisim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flloydzhou%2Fredisim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flloydzhou%2Fredisim/lists"}