{"id":14977747,"url":"https://github.com/schadokar/redis-go-server","last_synced_at":"2025-10-28T05:30:57.463Z","repository":{"id":113982990,"uuid":"224416660","full_name":"schadokar/redis-go-server","owner":"schadokar","description":"A prebuild golang server to work with redis db.","archived":false,"fork":false,"pushed_at":"2019-11-27T11:40:26.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T12:11:11.977Z","etag":null,"topics":["docker-image","golang","redis","redis-client","redis-db"],"latest_commit_sha":null,"homepage":null,"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/schadokar.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":"2019-11-27T11:37:09.000Z","updated_at":"2021-05-15T05:55:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"0d649cc0-c712-4b18-a1d5-204e7b491726","html_url":"https://github.com/schadokar/redis-go-server","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"b604b19e1b98c4389f4253bea80fcc4fbdfec7f2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schadokar%2Fredis-go-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schadokar%2Fredis-go-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schadokar%2Fredis-go-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schadokar%2Fredis-go-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schadokar","download_url":"https://codeload.github.com/schadokar/redis-go-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238603665,"owners_count":19499488,"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":["docker-image","golang","redis","redis-client","redis-db"],"created_at":"2024-09-24T13:56:15.187Z","updated_at":"2025-10-28T05:30:57.184Z","avatar_url":"https://github.com/schadokar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redis-Go-Server\r\n\r\nA prebuild golang server to work with redis db.\r\n\r\n## Dependencies\r\n\r\n- go-redis github.com/go-redis/redis/v7\r\n- gorilla/mux github.com/gorilla/mux\r\n\r\n## Docker Image\r\n\r\nThe docker image is hosted on [Docker Hub](https://hub.docker.com/r/schadokar/redis-go-server).\r\n\r\n## Prerequisite\r\n\r\nThe Redis DB must be up and running. It can be locally hosted, Redis docker image or cloud-based.\r\n\r\nUse docker-compose to pass the Redis DB details to the server.\r\n\r\nSet the environment variable of the redis-db:\r\n\r\n- REDIS_DB_URL=URL\r\n- REDIS_DB_PASSWORD=Password\r\n- REDIS_DB=db index\r\n\r\n**Note** If the password is an empty string `\"\"`, don't send the empty string.\r\n\r\n```\r\nREDIS_DB_PASSWORD=\r\n```\r\n\r\nIt will take that as an empty string.\r\n\r\n## Instructions\r\n\r\n#### Pull the image\r\n\r\n```docker\r\ndocker pull schadokar/redis-go-server\r\n```\r\n\r\n#### Create a docker-compose file\r\n\r\n```\r\nversion: \"2\"\r\n\r\nservices:\r\n  redis-db:\r\n    image: redis:alpine\r\n    ports:\r\n      - 6379:6379\r\n    container_name: redis-db\r\n\r\n  redis-go-server:\r\n    image: schadokar/redis-go-server:latest\r\n\r\n    environment:\r\n      - REDIS_DB_URL=redis-db:6379\r\n      - REDIS_DB_PASSWORD=\r\n      - REDIS_DB=0\r\n    ports:\r\n      - 8080:8080\r\n    depends_on:\r\n      - redis-db\r\n    container_name: redis-go-server\r\n```\r\n\r\nFirst, we're pulling the `redis:alpine` image and running it as `redis-db` container.  \r\nThe second image is `schadokar/redis-go-server` which is running as `redis-go-server` container.\r\n\r\nCheck the environment variables.\r\n\r\n### Endpoints of the server\r\n\r\nThere are 3 endpoints of the server:\r\n\r\n- POST METHOD **set**  \r\n  It takes a json object with 2 keys: \"key\" and \"value\"\r\n\r\n```\r\n{\r\n    \"key\": \"strongest-avenger\",\r\n    \"value\": \"thor\"\r\n}\r\n```\r\n\r\n- GET METHOD **get**  \r\n  Return all the keys stored in the Redis DB.\r\n- GET METHOD **get/{key}**  \r\n  Return the value of the key\r\n\r\n### Example\r\n\r\n- Run the docker-compose file\r\n\r\n```\r\ndocker-compose -f \u003cfile-path\u003e up -d\r\n\r\nOutput\r\n\r\ndocker-compose -f ./docker-compose.yaml up -d\r\nCreating network \"deployments_default\" with the default driver\r\nCreating redis-db ... done\r\nCreating redis-go-server ... done\r\n```\r\n\r\n- Save a key-value pair in the Redis DB using `cURL`\r\n\r\n```\r\ncurl -d '{\"key\":\"strongest-avenger\",\"value\":\"thor\"}' -X POST http://localhost:8080/set\r\n\r\nOutput\r\n\r\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\r\n                                 Dload  Upload   Total   Spent    Left  Speed\r\n100    64  100    22  100    42    687   1312 --:--:-- --:--:-- --:--:--  2000  \"Successfully Saved!\"\r\n```\r\n\r\n- Get the value of the key `strongest-avenger`\r\n\r\n```\r\ncurl -X GET http://localhost:8080/get/strongest-avenger\r\n\r\n% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\r\n                                 Dload  Upload   Total   Spent    Left  Speed\r\n 100     7  100     7    0     0    148      0 --:--:-- --:--:-- --:--:--   148   \"thor\"\r\n```\r\n\r\n- Get all the keys stored in the Redis DB\r\n\r\n```\r\ncurl -X GET http://localhost:8080/get\r\n\r\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\r\n                                 Dload  Upload   Total   Spent    Left  Speed\r\n100    22  100    22    0     0   1466      0 --:--:-- --:--:-- --:--:--  1466   [\"strongest-avenger\"]\r\n```\r\n\r\n# To build the image using the Dockerfile in the deployments\r\n\r\nOpen the terminal in the redis-go-server directory and run\r\n\r\n```docker\r\ndocker build -t \u003ctag of the image\u003e -f deployments/Dockerfile .\r\n```\r\n\r\n# To run the docker-compose\r\n\r\nOpen the terminal in the redis-go-server directory and run\r\n\r\n```docker\r\ndocker-compose -f deployments/docker-compose.yaml up -d\r\n```\r\n\r\n# References\r\n\r\n[Callicoder](https://www.callicoder.com/docker-golang-image-container-example/)  \r\n[Builder pattern vs. Multi-stage builds in Docker](https://blog.alexellis.io/mutli-stage-docker-builds)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschadokar%2Fredis-go-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschadokar%2Fredis-go-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschadokar%2Fredis-go-server/lists"}