{"id":19517224,"url":"https://github.com/dhyanio/discache","last_synced_at":"2025-04-15T21:26:53.288Z","repository":{"id":259857958,"uuid":"875919411","full_name":"dhyanio/discache","owner":"dhyanio","description":"Simple, Fast, and Distributed Cache Server in Go","archived":false,"fork":false,"pushed_at":"2024-12-14T16:49:20.000Z","size":21183,"stargazers_count":5,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T01:34:21.758Z","etag":null,"topics":["binary","cache","discache","distributed-systems","golang","grpc","raft","transport"],"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/dhyanio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2024-10-21T05:13:39.000Z","updated_at":"2025-02-24T15:31:08.000Z","dependencies_parsed_at":"2024-10-28T13:19:39.413Z","dependency_job_id":"acc5057c-1791-4090-889c-b65d3b287da0","html_url":"https://github.com/dhyanio/discache","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":0.12,"last_synced_commit":"76574d9c2034c79720c5b22183f60838b79e4441"},"previous_names":["dhyanio/discache"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyanio%2Fdiscache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyanio%2Fdiscache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyanio%2Fdiscache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyanio%2Fdiscache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhyanio","download_url":"https://codeload.github.com/dhyanio/discache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249156067,"owners_count":21221706,"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":["binary","cache","discache","distributed-systems","golang","grpc","raft","transport"],"created_at":"2024-11-11T00:01:15.556Z","updated_at":"2025-04-15T21:26:53.267Z","avatar_url":"https://github.com/dhyanio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./doc/discache.png\" alt=\"Discache\" width=\"600\"/\u003e\n\n[![release](https://img.shields.io/github/release/dhyanio/discache.svg)](https://github.com/dhyanio/discache/releases)\n[![tests](https://github.com/dhyanio/discache/actions/workflows/test.yaml/badge.svg)](https://github.com/dhyanio/discache/actions/workflows/test.yaml)\n[![linter](https://github.com/dhyanio/discache/actions/workflows/linter.yaml/badge.svg)](https://github.com/dhyanio/discache/actions/workflows/linter.yaml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/dhyanio/discache)](https://goreportcard.com/report/github.com/dhyanio/discache)\n![Go Version](https://img.shields.io/badge/go%20version-%3E=1.23-61CFDD.svg?style=flat-square)\n[![release](https://godoc.org/github.com/dhyanio/discache?status.svg)](https://pkg.go.dev/github.com/dhyanio/discache?tab=doc)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)\n\nDiscache is a powerful, but simple memory cache in Golang. Using TCP and binary as a transporter makes it very performant.\n\n# Table of Contents\n- [Installation](#installation)\n- [Cli](#cli)\n- [Client](#client)\n\n### Installation\n\n#### Discache\n\n**From releases**\nThis installs binary.\n\n* Linux\n```\ncurl -LO \"https://github.com/dhyanio/discache/releases/download/$(curl -s https://api.github.com/repos/dhyanio/discache/releases/latest | grep tag_name | cut -d '\"' -f 4)/discache-linux-amd64\"\nchmod +x discache-linux-amd64\nsudo mv discache-linux-amd64 /usr/local/bin/discache\n```\n* MacOS\n```\ncurl -LO \"https://github.com/dhyanio/discache/releases/download/$(curl -s https://api.github.com/repos/dhyanio/discache/releases/latest | grep tag_name | cut -d '\"' -f 4)/discache-darwin-amd64\"\nchmod +x discache-darwin-amd64\nsudo mv discache-darwin-amd64 /usr/local/bin/discache\n```\n\n**From source**\n1.  Run `git clone \u003cdiscache repo\u003e \u0026\u0026 cd discache/`\n2.  Run `make build`\n\n## CLI\nA CLI tool has commands\n\n### Makefile Targets\n#### Variables\n- `LISTEN_ADDR` - Address for the server to listen on (default: `:4000`).\n- `LEADER_ADDR` - Address of the leader node (default: `:3000`).\n\nThese can be passed as arguments when running specific commands.\n\n### 📚 Usage\n- Run the Project\n\n```bash\nmake run\n```\nIt runs the binary after building it.\n\n- Run the Tests\n\n```bash\nmake test\n```\nRuns all tests with verbose output.\n\n- Lint the Project\n\n```bash\nmake lint\n```\nRuns golangci-lint on the codebase. Ensure golangci-lint is installed.\n\n- Format the Code\n\n```bash\nmake fmt\n```\nFormats the code using go fmt.\n\n- Clean the Build Files\n\n```bash\nmake clean\n```\nRemoves the bin/ directory and all generated files.\n\n### Example Usage\nTo start a leader\n```bash\nmake run NAME:node1 LISTEN_ADDR=:3000\n```\n\nTo start a follower node with a custom `LISTEN_ADDR` and `LEADER_ADDR`\n```bash\nmake leader NAME=node1 LISTEN_ADDR=:3000 Leader_NAME=node1\n```\n\n## Client\nA Go client for connecting to an LRU cache server over TCP. This client allows users to perform Get and Put operations on the cache, handling network communication and TTL (time-to-live) for cache entries.\n\n### 🔧 Features\n- Get: Retrieve a value by its key.\n- Put: Store a value with a specified TTL.\n- Connection Management: Establishes and closes TCP connections.\n- Error Handling: Returns detailed error messages for failed operations.\n\n### 🚀 Installation\n- Prerequisites: Make sure you have Go installed.\n- Clone the repository and navigate to the project directory.\n- Build the Client:\n\n```bash\ngo build -o lru_client client.go\n```\n### 📚 Usage\n#### Initialize the Client\nTo create a new client instance, use New with the server endpoint and optional configurations:\n\n```go\nimport \"github.com/dhyanio/discache/client\"\n\nfunc main() {\n    endpoint := \"localhost:9080\" // port 9080 is the default for discache client-server\n    opts := client.Options{}\n    client, err := client.New(endpoint, opts)\n    if err != nil {\n        log.Fatalf(\"Failed to connect to discache server: %v\", err)\n    }\n    defer cacheClient.Close()\n}\n\n```\n\n#### Using Get and Put Methods\n`Put` a key-value pair into the cache with a specified TTL (in seconds):\n\n```go\nkey := []byte(\"foo\")\nvalue := []byte(\"bar\")\nttl := 60 // TTL in seconds\n\nerr := client.Put(context.Background(), key, value, ttl)\nif err != nil {\n    log.Printf(\"Failed to put key: %v\", err)\n}\n```\n\n`Get` a value by key:\n\n```go\nvalue, err := client.Get(context.Background(), key)\nif err != nil {\n    log.Printf(\"Failed to get key: %v\", err)\n} else {\n    log.Printf(\"Value: %s\", string(value))\n}\n```\n#### Close the Client\nAlways close the connection when you're done:\n\n```go\ndefer cacheClient.Close()\n```\n\n## ❗Error Handling\nErrors returned by `Get` and `Put` methods include:\n\n- `Key Not Found`: if the key doesn’t exist.\n- `Connection Errors`: issues in TCP communication with the server.\n- `Non-OK Status`: unexpected server responses.\n\n## 🤝 Contributing\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n1. Fork the repository.\n2. Create your feature branch (git checkout -b feature/new-feature).\n3. Commit your changes (git commit -am 'Add new feature').\n4. Push to the branch (git push origin feature/new-feature).\n5. Create a new Pull Request.\n\n## 📜 License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## ❤️ Acknowledgements\n\nThanks to the Go community for their support and contributions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhyanio%2Fdiscache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhyanio%2Fdiscache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhyanio%2Fdiscache/lists"}