{"id":17035406,"url":"https://github.com/hhxsv5/go-redis-memory-analysis","last_synced_at":"2025-04-13T08:26:27.565Z","repository":{"id":41274823,"uuid":"110549658","full_name":"hhxsv5/go-redis-memory-analysis","owner":"hhxsv5","description":"🔎 Analyzing memory of redis is to find the keys(prefix) which used a lot of memory, export the analysis result into csv file. ","archived":false,"fork":false,"pushed_at":"2024-05-30T06:37:53.000Z","size":440,"stargazers_count":142,"open_issues_count":2,"forks_count":26,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-15T08:46:40.778Z","etag":null,"topics":["analysis","export-csvfile","memory","occupancy","redis","usage"],"latest_commit_sha":null,"homepage":"","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/hhxsv5.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":"2017-11-13T13:09:41.000Z","updated_at":"2024-08-16T03:34:01.000Z","dependencies_parsed_at":"2024-10-25T19:12:10.018Z","dependency_job_id":"e430cbb2-861f-46da-91b6-8b67c406ebed","html_url":"https://github.com/hhxsv5/go-redis-memory-analysis","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhxsv5%2Fgo-redis-memory-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhxsv5%2Fgo-redis-memory-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhxsv5%2Fgo-redis-memory-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhxsv5%2Fgo-redis-memory-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hhxsv5","download_url":"https://codeload.github.com/hhxsv5/go-redis-memory-analysis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248682839,"owners_count":21144832,"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","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":["analysis","export-csvfile","memory","occupancy","redis","usage"],"created_at":"2024-10-14T08:46:47.242Z","updated_at":"2025-04-13T08:26:27.547Z","avatar_url":"https://github.com/hhxsv5.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Redis memory analysis\n======\n\n🔎  Analyzing memory of redis is to find the keys(prefix) which used a lot of memory, export the analysis result into csv file.\n\n[![GoDoc](https://godoc.org/github.com/hhxsv5/go-redis-memory-analysis?status.svg)](https://godoc.org/github.com/hhxsv5/go-redis-memory-analysis)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hhxsv5/go-redis-memory-analysis)](https://goreportcard.com/report/github.com/hhxsv5/go-redis-memory-analysis)\n[![Sourcegraph](https://sourcegraph.com/github.com/hhxsv5/go-redis-memory-analysis/-/badge.svg)](https://sourcegraph.com/github.com/hhxsv5/go-redis-memory-analysis?badge)\n\n## Binary File Usage\n\n1. Download the appropriate binary file from [Releases](https://github.com/hhxsv5/go-redis-memory-analysis/releases)\n\n2. Run\n\n```Shell\n# help\n./redis-memory-analysis-linux-amd64 -h\nUsage of ./redis-memory-analysis-darwin-amd64:\n  -ip string\n    \tThe host of redis (default \"127.0.0.1\")\n  -password string\n    \tThe password of redis (default \"\")\n  -port uint\n    \tThe port of redis (default 6379)\n  -rdb string\n    \tThe rdb file of redis (default \"\")\n  -prefixes string\n    \tThe prefixes list of redis key, be split by '//', special pattern characters need to escape by '\\' (default \"#//:\")\n  -reportPath string\n    \tThe csv file path of analysis result (default \"./reports\")\n\n# run by connecting to redis\n./redis-memory-analysis-linux-amd64 -ip=\"127.0.0.1\" -port=6380 -password=\"abc\" -prefixes=\"#//:\"\n\n# run by redis rdb file\n./redis-memory-analysis-linux-amd64 -rdb=\"./6379_dump.rdb\" -prefixes=\"#//:\"\n```\n\n## Source Code Usage\n\n1. Install\n\n```Shell\n//cd your-root-folder-of-project\n// dep init\ndep ensure -add github.com/hhxsv5/go-redis-memory-analysis@~2.0.0\n```\n\n2. Run\n\n- Analyze keys by connecting to redis directly.\n\n```Go\nanalysis := NewAnalysis()\n//Open redis: 127.0.0.1:6379 without password\nerr := analysis.Open(\"127.0.0.1\", 6379, \"\")\ndefer analysis.Close()\nif err != nil {\n    fmt.Println(\"something wrong:\", err)\n    return\n}\n\n//Scan the keys which can be split by '#' ':'\n//Special pattern characters need to escape by '\\'\nanalysis.Start([]string{\"#\", \":\"})\n\n//Find the csv file in default target folder: ./reports\n//CSV file name format: redis-analysis-{host:port}-{db}.csv\n//The keys order by count desc\nerr = analysis.SaveReports(\"./reports\")\nif err == nil {\n    fmt.Println(\"done\")\n} else {\n    fmt.Println(\"error:\", err)\n}\n```\n\n- Analyze keys by redis `RDB` file, but cannot work out the size of key.\n\n```Go\nanalysis := NewAnalysis()\n//Open redis rdb file: ./6379_dump.rdb\nerr := analysis.OpenRDB(\"./6379_dump.rdb\")\ndefer analysis.CloseRDB()\nif err != nil {\n    fmt.Println(\"something wrong:\", err)\n    return\n}\n\n//Scan the keys which can be split by '#' ':'\n//Special pattern characters need to escape by '\\'\nanalysis.StartRDB([]string{\"#\", \":\"})\n\n//Find the csv file in default target folder: ./reports\n//CSV file name format: redis-analysis-{host:port}-{db}.csv\n//The keys order by count desc\nerr = analysis.SaveReports(\"./reports\")\nif err == nil {\n    fmt.Println(\"done\")\n} else {\n    fmt.Println(\"error:\", err)\n}\n```\n\n![CSV](https://raw.githubusercontent.com/hhxsv5/go-redis-memory-analysis/master/examples/demo.png)\n\n## Another tool implemented by PHP\n\n[redis-memory-analysis](https://github.com/hhxsv5/redis-memory-analysis)\n\n\n## License\n\n[MIT](https://github.com/hhxsv5/go-redis-memory-analysis/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhxsv5%2Fgo-redis-memory-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhhxsv5%2Fgo-redis-memory-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhxsv5%2Fgo-redis-memory-analysis/lists"}