{"id":20960410,"url":"https://github.com/anthdm/ggcache","last_synced_at":"2025-05-14T07:30:36.309Z","repository":{"id":97194895,"uuid":"588688936","full_name":"anthdm/ggcache","owner":"anthdm","description":"FAST AF F","archived":false,"fork":false,"pushed_at":"2024-03-20T19:00:29.000Z","size":5906,"stargazers_count":38,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T14:21:35.523Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/anthdm.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}},"created_at":"2023-01-13T18:38:45.000Z","updated_at":"2025-03-18T09:56:00.000Z","dependencies_parsed_at":"2023-04-25T18:31:14.955Z","dependency_job_id":null,"html_url":"https://github.com/anthdm/ggcache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthdm%2Fggcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthdm%2Fggcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthdm%2Fggcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthdm%2Fggcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthdm","download_url":"https://codeload.github.com/anthdm/ggcache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254094742,"owners_count":22013631,"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":"2024-11-19T01:58:53.819Z","updated_at":"2025-05-14T07:30:34.451Z","avatar_url":"https://github.com/anthdm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ggcache\n\n`ggcache` is a flexible and lightweight in-memory cache package for Go, suitable for both single-cache applications and distributed systems with multiple clients.\n\n## Overview\n\nThis package provides a basic in-memory caching mechanism with support for key-value storage, expiration time, and concurrent read and write safety. It is designed to be versatile and adaptable to various use cases, from standalone applications to distributed systems where multiple clients share a common cache.\n\n## Features\n\n- **Concurrent Safety:** The cache utilizes a `sync.RWMutex` to ensure safe access and modification of data in a concurrent environment.\n\n- **Expiration Time:** Cached items can have an optional expiration time, allowing automatic removal of entries after a specified duration.\n\n- **Client-Server Architecture:** The package supports a client-server architecture, enabling multiple clients to interact with a centralized cache server.\n\n## Installation\n\nTo use `ggcache` in your Go project, you can install it using the following:\n\n```bash\ngo get github.com/anthdm/ggcache\n```\n\n## Single Cache Example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/anthdm/ggcache\"\n)\n\nfunc main() {\n\t// Create a new cache instance\n\tcache := ggcache.New()\n\n\t// Set a key-value pair in the cache\n\tkey := []byte(\"exampleKey\")\n\tvalue := []byte(\"exampleValue\")\n\terr := cache.Set(key, value, time.Second*30)\n\tif err != nil {\n\t\tfmt.Println(\"Error:\", err)\n\t}\n\n\t// Get the value from the cache\n\tresult, err := cache.Get(key)\n\tif err != nil {\n\t\tfmt.Println(\"Error:\", err)\n\t} else {\n\t\tfmt.Println(\"Value:\", string(result))\n\t}\n\n\t// Check if a key exists in the cache\n\tif cache.Has(key) {\n\t\tfmt.Println(\"Key exists in the cache.\")\n\t}\n\n\t// Delete a key from the cache\n\terr = cache.Delete(key)\n\tif err != nil {\n\t\tfmt.Println(\"Error:\", err)\n\t}\n}\n```\n\n## Contributing\nFeel free to contribute to the development of ggcache by submitting issues or pull requests.\n\n## License\nThis package is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthdm%2Fggcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthdm%2Fggcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthdm%2Fggcache/lists"}