{"id":38369367,"url":"https://github.com/doutivity/research-online-redis-go","last_synced_at":"2026-01-17T03:26:26.797Z","repository":{"id":182928652,"uuid":"618961804","full_name":"doutivity/research-online-redis-go","owner":"doutivity","description":"Efficiently store online with Redis and Go","archived":false,"fork":false,"pushed_at":"2024-03-31T22:35:23.000Z","size":65,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-06-21T18:53:29.757Z","etag":null,"topics":["dragonflydb","keydb","redis"],"latest_commit_sha":null,"homepage":"https://dou.ua/forums/topic/35260/","language":"Go","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/doutivity.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":"2023-03-25T21:11:22.000Z","updated_at":"2023-12-12T08:05:29.000Z","dependencies_parsed_at":"2024-03-31T23:27:15.816Z","dependency_job_id":"46d692cc-09e1-4408-9e9c-36237637099a","html_url":"https://github.com/doutivity/research-online-redis-go","commit_stats":null,"previous_names":["doutivity/research-online-redis-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/doutivity/research-online-redis-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doutivity%2Fresearch-online-redis-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doutivity%2Fresearch-online-redis-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doutivity%2Fresearch-online-redis-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doutivity%2Fresearch-online-redis-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doutivity","download_url":"https://codeload.github.com/doutivity/research-online-redis-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doutivity%2Fresearch-online-redis-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["dragonflydb","keydb","redis"],"created_at":"2026-01-17T03:26:26.707Z","updated_at":"2026-01-17T03:26:26.781Z","avatar_url":"https://github.com/doutivity.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Efficiently store online with Redis and Go\n- [Збереження стану онлайну користувача в Redis](https://dou.ua/forums/topic/35260/)\n- [Hash, Set чи Sorted set. Який тип даних вибрати для збереження стану онлайну користувача в Redis?](https://dou.ua/forums/topic/44655/)\n- [Efficiently store online with Redis and Rust](https://github.com/doutivity/research-online-redis-rust)\n\n# Support Ukraine 🇺🇦\n- Help Ukraine via [SaveLife fund](https://savelife.in.ua/en/donate-en/)\n- Help Ukraine via [Dignitas fund](https://dignitas.fund/donate/)\n- Help Ukraine via [National Bank of Ukraine](https://bank.gov.ua/en/news/all/natsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi)\n- More info on [war.ukraine.ua](https://war.ukraine.ua/) and [MFA of Ukraine](https://twitter.com/MFA_Ukraine)\n\n# Databases\n| Name                                                    | Stars  | Language                               |\n|---------------------------------------------------------|--------|----------------------------------------|\n| [Redis](https://github.com/redis/redis)                 | 64300+ | [C](https://dou.ua/forums/tags/C/)     |\n| [KeyDB](https://github.com/Snapchat/KeyDB)              | 10100+ | [C++](https://dou.ua/forums/tags/C++/) |\n| [DragonflyDB](https://github.com/dragonflydb/dragonfly) | 23300+ | [C++](https://dou.ua/forums/tags/C++/) |\n| [Garnet](https://github.com/microsoft/garnet)           | 7900+  | [C#](https://dou.ua/forums/tags/C%23/) |\n\n# Data structure usage examples\n### Hash\n```bash\ndocker exec research-online-redis-1 redis-cli monitor\n```\n```bash\ndocker exec research-online-redis-go-app go test ./... -v -run=TestRedisHashOnlineStorage -count=1\n```\n```text\nflushall\nhset \"h:online:main\" \"10000001\" \"1679800725\"\nhset \"h:online:main\" \"10000002\" \"1679800730\"\nhset \"h:online:main\" \"10000003\" \"1679800735\"\nhlen \"h:online:main\"\nrename \"h:online:main\" \"h:online:tmp\"\nhgetall \"h:online:tmp\"\n```\n### Sorted Set\n```bash\ndocker exec research-online-redis-1 redis-cli monitor\n```\n```bash\ndocker exec research-online-redis-go-app go test ./... -v -run=TestRedisSortedSetOnlineStorage -count=1\n```\n```text\nflushall\nzadd \"z:online:main\" \"1679800725\" \"10000001\"\nzadd \"z:online:main\" \"1679800730\" \"10000002\"\nzadd \"z:online:main\" \"1679800735\" \"10000003\"\nzcard \"z:online:main\"\nrename \"z:online:main\" \"z:online:tmp\"\nzrange \"z:online:tmp\" \"0\" \"-1\" \"withscores\"\n```\n### Set\n```bash\ndocker exec research-online-redis-1 redis-cli monitor\n```\n```bash\ndocker exec research-online-redis-go-app go test ./... -v -run=TestRedisSetOnlineStorage -count=1\n```\n```text\nflushall\nsadd \"s:online:main:1679800725\" \"10000001\"\nsadd \"s:online:main:1679800730\" \"10000002\"\nsadd \"s:online:main:1679800735\" \"10000003\"\nkeys \"s:online:main:*\"\nscard \"s:online:main:1679800730\"\nscard \"s:online:main:1679800725\"\nscard \"s:online:main:1679800735\"\nkeys \"s:online:main:*\"\nrename \"s:online:main:1679800730\" \"s:online:tmp\"\nsmembers \"s:online:tmp\"\nrename \"s:online:main:1679800725\" \"s:online:tmp\"\nsmembers \"s:online:tmp\"\nrename \"s:online:main:1679800735\" \"s:online:tmp\"\nsmembers \"s:online:tmp\"\n```\n\n# Testing\n```bash\nmake env-up\nmake test\nmake env-down\n```\n```text\n=== RUN   TestGoOnlineStorage\n--- PASS: TestGoOnlineStorage (0.00s)\n=== RUN   TestRedisHashOnlineStorage\n--- PASS: TestRedisHashOnlineStorage (0.00s)\n=== RUN   TestKeydbHashOnlineStorage\n--- PASS: TestKeydbHashOnlineStorage (0.00s)\n=== RUN   TestDragonflydbHashOnlineStorage\n--- PASS: TestDragonflydbHashOnlineStorage (0.00s)\n=== RUN   TestGarnetHashOnlineStorage\n--- PASS: TestGarnetHashOnlineStorage (0.00s)\n=== RUN   TestRedisPing\n--- PASS: TestRedisPing (0.00s)\n=== RUN   TestKeydbPing\n--- PASS: TestKeydbPing (0.00s)\n=== RUN   TestDragonflydbPing\n--- PASS: TestDragonflydbPing (0.00s)\n=== RUN   TestRedisSetOnlineStorage\n--- PASS: TestRedisSetOnlineStorage (0.00s)\n=== RUN   TestKeydbSetOnlineStorage\n--- PASS: TestKeydbSetOnlineStorage (0.00s)\n=== RUN   TestDragonflydbSetOnlineStorage\n--- PASS: TestDragonflydbSetOnlineStorage (0.01s)\n=== RUN   TestGarnetSetOnlineStorage\n--- PASS: TestGarnetSetOnlineStorage (0.11s)\n=== RUN   TestRedisSortedSetOnlineStorage\n--- PASS: TestRedisSortedSetOnlineStorage (0.00s)\n=== RUN   TestKeydbSortedSetOnlineStorage\n--- PASS: TestKeydbSortedSetOnlineStorage (0.00s)\n=== RUN   TestDragonflydbSortedSetOnlineStorage\n--- PASS: TestDragonflydbSortedSetOnlineStorage (0.02s)\n=== RUN   TestGarnetSortedSetOnlineStorage\n--- PASS: TestGarnetSortedSetOnlineStorage (0.00s)\nPASS\nok  \tgithub.com/doutivity/research-online-redis-go\t0.154s\n```\n\n# Benchmark\n```bash\nmake bench\n# MODE=sequence go test ./... -v -bench='Go'                         -benchmem -benchtime=1000000x -count=5 | tee ./output/bench-go-1000000x-sequence.txt\n# MODE=sequence go test ./... -v -bench='Redis(Hash|SortedSet|Set)'  -benchmem -benchtime=1000000x -count=5 | tee ./output/bench-redis-1000000x-sequence.txt\n# MODE=sequence go test ./... -v -bench='Keydb(Hash|SortedSet|Set)'  -benchmem -benchtime=1000000x -count=5 | tee ./output/bench-keydb-1000000x-sequence.txt\n# MODE=sequence go test ./... -v -bench='Dragonflydb(SortedSet|Set)' -benchmem -benchtime=1000000x -count=5 | tee ./output/bench-dragonflydb-1000000x-sequence.txt\n# MODE=parallel go test ./... -v -bench='Go'                         -benchmem -benchtime=1000000x -count=5 | tee ./output/bench-go-1000000x-parallel.txt\n# MODE=parallel go test ./... -v -bench='Redis(Hash|SortedSet|Set)'  -benchmem -benchtime=1000000x -count=5 | tee ./output/bench-redis-1000000x-parallel.txt\n# MODE=parallel go test ./... -v -bench='Keydb(Hash|SortedSet|Set)'  -benchmem -benchtime=1000000x -count=5 | tee ./output/bench-keydb-1000000x-parallel.txt\n# MODE=parallel go test ./... -v -bench='Dragonflydb(SortedSet|Set)' -benchmem -benchtime=1000000x -count=5 | tee ./output/bench-dragonflydb-1000000x-parallel.txt\n# benchstat ./output/bench-go-1000000x-sequence.txt\n# benchstat ./output/bench-redis-1000000x-sequence.txt\n# benchstat ./output/bench-keydb-1000000x-sequence.txt\n# benchstat ./output/bench-dragonflydb-1000000x-sequence.txt\n# benchstat ./output/bench-go-1000000x-parallel.txt\n# benchstat ./output/bench-redis-1000000x-parallel.txt\n# benchstat ./output/bench-keydb-1000000x-parallel.txt\n# benchstat ./output/bench-dragonflydb-1000000x-parallel.txt\n```\n| Database name | Data structure | sequence time/op | parallel time/op |\n|---------------|----------------|------------------|------------------|\n| Go            | map[int]int    | 515ns ± 9%       | 696ns ± 8%       |\n| Redis         | Hash           | 33.5µs ± 6%      | 13.9µs ±24%      |\n| KeyDB         | Hash           | 36.9µs ± 2%      | 14.5µs ±23%      |\n| DragonflyDB   | Hash           | 44.0µs ± 2%      | 13.6µs ±12%      |\n| Redis         | Sorted Set     | 34.4µs ± 1%      | 13.5µs ± 6%      |\n| KeyDB         | Sorted Set     | 38.6µs ± 1%      | 14.1µs ± 2%      |\n| DragonflyDB   | Sorted Set     | 52.9µs ±15%      | 16.3µs ± 8%      |\n| Redis         | Set            | 32.6µs ± 1%      | 12.4µs ± 2%      |\n| KeyDB         | Set            | 36.7µs ± 1%      | 13.7µs ± 3%      |\n| DragonflyDB   | Set            | 45.9µs ± 4%      | 14.4µs ±16%      |\n\n# Used memory\n```bash\nmake bench-redis-memory-1m\nmake bench-keydb-memory-1m\nmake bench-dragonflydb-memory-1m\n# ...\nmake bench-redis-memory-25m\nmake bench-keydb-memory-25m\nmake bench-dragonflydb-memory-25m\n```\n```bash\n# docker exec research-online-redis-1 redis-cli flushall\n# docker exec -e MODE=parallel research-online-redis-go-app go test ./... -v -run=$^ -bench='Redis(Hash)' -benchmem -benchtime=25000000x -count=1\n# docker exec research-online-redis-1 redis-cli info memory | tee ./output/redis-memory-hash-25m.txt\n#\n# docker exec research-online-redis-1 redis-cli flushall\n# docker exec -e MODE=parallel research-online-redis-go-app go test ./... -v -run=$^ -bench='Redis(SortedSet)' -benchmem -benchtime=25000000x -count=1\n# docker exec research-online-redis-1 redis-cli info memory | tee ./output/redis-memory-sorted-set-25m.txt\n#\n# docker exec research-online-redis-1 redis-cli flushall\n# docker exec -e MODE=parallel research-online-redis-go-app go test ./... -v -run=$^ -bench='Redis(Set)' -benchmem -benchtime=25000000x -count=1\n# docker exec research-online-redis-1 redis-cli info memory | tee ./output/redis-memory-set-25m.txt\n```\n| Database name | Data structure | Users      | Memory                                                          |\n|---------------|----------------|------------|-----------------------------------------------------------------|\n| Redis         | Hash           | 1 000 000  | 62.64 MB                                                        |\n| KeyDB         | Hash           | 1 000 000  | 63.49 MB                                                        |\n| DragonflyDB   | Hash           | 1 000 000  | 61.51 MB                                                        |\n| Redis         | Hash           | 10 000 000 | 727.20 MB                                                       |\n| KeyDB         | Hash           | 10 000 000 | 728.14 MB                                                       |\n| DragonflyDB   | Hash           | 10 000 000 | 622.59 MB                                                       |\n| Redis         | Hash           | 25 000 000 | 1592.14 MB                                                      |\n| KeyDB         | Hash           | 25 000 000 | 1593.27 MB                                                      |\n| DragonflyDB   | Hash           | 25 000 000 | 1481.70  MB                                                     |\n| Redis         | Sorted Set     | 1 000 000  | 91.09 MB                                                        |\n| KeyDB         | Sorted Set     | 1 000 000  | 91.93 MB                                                        |\n| DragonflyDB   | Sorted Set     | 1 000 000  | 107.87 MB                                                       |\n| Redis         | Sorted Set     | 10 000 000 | 1011.78 MB                                                      |\n| KeyDB         | Sorted Set     | 10 000 000 | 1012.64 MB                                                      |\n| DragonflyDB   | Sorted Set     | 10 000 000 | 1161.64 MB                                                      |\n| Redis         | Sorted Set     | 25 000 000 | 2303.58 MB                                                      |\n| KeyDB         | Sorted Set     | 25 000 000 | 2304.70 MB                                                      |\n| DragonflyDB   | Sorted Set     | 25 000 000 | 2675.25 MB                                                      |\n| Redis         | Set            | 1 000 000  | 48.14 MB                                                        |\n| KeyDB         | Set            | 1 000 000  | 49.02 MB                                                        |\n| DragonflyDB   | Set            | 1 000 000  | 32.60 MB                                                        |\n| Redis         | Set            | 10 000 000 | 469.57 MB                                                       |\n| KeyDB         | Set            | 10 000 000 | 471.44 MB                                                       |\n| DragonflyDB   | Set            | 10 000 000 | 297.01 MB                                                       |\n| Redis         | Set            | 25 000 000 | 1169.33 MB                                                      |\n| KeyDB         | Set            | 25 000 000 | 1175.45 MB                                                      |\n| DragonflyDB   | Set            | 25 000 000 | unknown, cause store less then expected, 15276400 from 25000000 |\n\n# Batch insert 10k rows x 10k times benchmark\n```bash\nmake bench-redis-memory-10k-batch-10k\nmake bench-keydb-memory-10k-batch-10k\nmake bench-dragonflydb-memory-10k-batch-10k\n```\n```bash\n# docker exec research-online-redis-1 redis-cli flushall\n# docker exec -e MODE=parallel -e BATCH=10000 research-online-redis-go-app go test ./... -v -run=$$^ -bench='Redis(Hash)' -benchmem -benchtime=10000x -count=1\n# docker exec research-online-redis-1 redis-cli info memory | tee ./output/redis-memory-hash-10k-batch-10k.txt\n#\n# docker exec research-online-redis-1 redis-cli flushall\n# docker exec -e MODE=parallel -e BATCH=10000 research-online-redis-go-app go test ./... -v -run=$$^ -bench='Redis(SortedSet)' -benchmem -benchtime=10000x -count=1\n# docker exec research-online-redis-1 redis-cli info memory | tee ./output/redis-memory-sorted-set-10k-batch-10k.txt\n#\n# docker exec research-online-redis-1 redis-cli flushall\n# docker exec -e MODE=parallel -e BATCH=10000 research-online-redis-go-app go test ./... -v -run=$$^ -bench='Redis(Set)' -benchmem -benchtime=10000x -count=1\n# docker exec research-online-redis-1 redis-cli info memory | tee ./output/redis-memory-set-10k-batch-10k.txt\n#\n# docker exec research-online-redis-1 redis-cli flushall\n```\n\n| Database name | Data structure | parallel time/op                                                 |\n|---------------|----------------|------------------------------------------------------------------|\n| Redis         | Hash           | 8232276 ns/op                                                    |\n| KeyDB         | Hash           | 21357358 ns/op                                                   |\n| DragonflyDB   | Hash           | 6716157 ns/op                                                    |\n| Redis         | Sorted Set     | 12016807 ns/op                                                   |\n| KeyDB         | Sorted Set     | 15114051 ns/op                                                   |\n| DragonflyDB   | Sorted Set     | 9535106 ns/op                                                    |\n| Redis         | Set            | 3187424 ns/op                                                    |\n| KeyDB         | Set            | 3233770 ns/op                                                    |\n| DragonflyDB   | Set            | unknown, cause store less then expected, 15622200 from 100000000 |\n\n| Database name | Data structure | Memory                                                           |\n|---------------|----------------|------------------------------------------------------------------|\n| Redis         | Hash           | 6.72 GB                                                          |\n| KeyDB         | Hash           | 6.22 GB                                                          |\n| DragonflyDB   | Hash           | 5.77 GB                                                          |\n| Redis         | Sorted Set     | 9.00 GB                                                          |\n| KeyDB         | Sorted Set     | 9.00 GB                                                          |\n| DragonflyDB   | Sorted Set     | 10.44 GB                                                         |\n| Redis         | Set            | 4.58 GB                                                          |\n| KeyDB         | Set            | 4.59 GB                                                          |\n| DragonflyDB   | Set            | unknown, cause store less then expected, 15622200 from 100000000 |\n\n# Star history of Redis vs KeyDB vs DragonflyDB\n[![Star History Chart](https://api.star-history.com/svg?repos=redis/redis,Snapchat/KeyDB,dragonflydb/dragonfly,microsoft/garnet\u0026type=Date)](https://star-history.com/#redis/redis\u0026Snapchat/KeyDB\u0026dragonflydb/dragonfly\u0026microsoft/garnet\u0026Date)\n\n# Versions\n```bash\ndocker pull redis:latest\ndocker pull eqalpha/keydb:latest\ndocker pull docker.dragonflydb.io/dragonflydb/dragonfly\ndocker pull ghcr.io/microsoft/garnet\n```\n```bash\ndocker image inspect redis:latest --format '{{.RepoDigests}} {{.Size}}'\ndocker image inspect eqalpha/keydb:latest --format '{{.RepoDigests}} {{.Size}}'\ndocker image inspect docker.dragonflydb.io/dragonflydb/dragonfly --format '{{.RepoDigests}} {{.Size}}'\ndocker image inspect ghcr.io/microsoft/garnet --format '{{.RepoDigests}} {{.Size}}'\n```\n| Database name | Docker image size | Docker image                                                            |\n|---------------|-------------------|-------------------------------------------------------------------------|\n| Redis         | 131.32 MB         | sha256:3134997edb04277814aa51a4175a588d45eb4299272f8eff2307bbf8b39e4d43 |\n| KeyDB         | 130.39 MB         | sha256:6537505c42355ca1f571276bddf83f5b750f760f07b2a185a676481791e388ac |\n| DragonflyDB   | 106.65 MB         | sha256:48d7f1679a895702262808c83689df94b14d40c07401fad90723ad164d271150 |\n| Garnet        | 196.50 MB         | sha256:0da3da0cd45d8a7084d670b7b1a96748cea40917ed054fc98840ce6e4036b97b |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoutivity%2Fresearch-online-redis-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoutivity%2Fresearch-online-redis-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoutivity%2Fresearch-online-redis-go/lists"}