{"id":27038357,"url":"https://github.com/neulhan/go-redis","last_synced_at":"2025-04-05T02:31:24.057Z","repository":{"id":102379586,"uuid":"259318258","full_name":"Neulhan/go-redis","owner":"Neulhan","description":"Go redis client tutorial","archived":false,"fork":false,"pushed_at":"2020-05-01T07:50:15.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-03T16:31:57.644Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/Neulhan.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-04-27T12:52:44.000Z","updated_at":"2024-06-19T09:07:14.458Z","dependencies_parsed_at":null,"dependency_job_id":"6852885e-357f-4bbd-b8d9-233ffd572524","html_url":"https://github.com/Neulhan/go-redis","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neulhan%2Fgo-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neulhan%2Fgo-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neulhan%2Fgo-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neulhan%2Fgo-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neulhan","download_url":"https://codeload.github.com/Neulhan/go-redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247279295,"owners_count":20912857,"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":[],"created_at":"2025-04-05T02:30:51.625Z","updated_at":"2025-04-05T02:31:23.874Z","avatar_url":"https://github.com/Neulhan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Redis 초간단 튜토리얼 해보기\n[korean]()  [english]()\n\n\nfrom [https://github.com/go-redis/redis](https://github.com/go-redis/redis)\n\n## 설치하기\n\n```bash\ngo mod init github.com/my/repo\ngo get github.com/go-redis/redis/v7\n```\n\n## import\n\n```go\nimport \"github.com/go-redis/redis\"\n```\n\n## ping\n\n```go\nfunc ping() {\n\tredisClient := redis.NewClient(\u0026redis.Options{\n\t\tAddr:     \"localhost:6379\", // redis 서버 주소 (redis 의 디폴트 포트 6379 로컬호스트)\n\t\tPassword: \"\",               // redis 비밀번호\n\t\tDB:       0,                // redis DB 번호 선택\n\t})\n\t// Ping 함수 (redis 서버는 사용자와 탁구를 칠 수 있습니다 하하)\n\tpong, err := redisClient.Ping().Result()\n\tfmt.Println(pong, err)\n}\n```\n\n## redis set\n\n```go\n// redis 에 cache set\nerr := redisClient.Set(\"key\", \"value\", 0).Err()\nif err != nil {\n\tpanic(err)\n}\n```\n\n## redis get\n\n```go\n// redis 에서 cache get\nval, err := redisClient.Get(\"key\").Result()\n\nif err != nil {\n\tpanic(err)\n}\n\nfmt.Println(\"key\", val)\n```\n\n## redis 예외처리\n\n```go\n// redis client 에 key 값이 존재하지 않는 경우 예외처리\nval2, err := redisClient.Get(\"key2\").Result()\nif err == redis.Nil {\n\t// key 에 대응되는 값이 존재하지 않을 경우\n\tfmt.Println(\"key2 does not exist\")\n} else if err != nil {\n\t// 에러 발생\n\tpanic(err)\n} else {\n\t// key 에 대응되는 값을 찾았을 경우\n\tfmt.Println(\"key2\", val2)\n}\n```\n\n## 후기\n\nmain 함수에서 redis client 를 선언해주고, 필요할 때 가져다 쓰면 될 듯.  \n이것을 go echo 에 보다 효과적으로 붙이는 방법은 좀 더 찾아봐야 할 듯하다.\n\n곧 Go Echo 에 적용하는 방법도 간단한 튜토리얼로 올리고 링크를 아래에 첨부하도록 하겠습니다.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneulhan%2Fgo-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneulhan%2Fgo-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneulhan%2Fgo-redis/lists"}