{"id":41688910,"url":"https://github.com/qshuai/lru","last_synced_at":"2026-01-24T20:06:25.572Z","repository":{"id":117747856,"uuid":"189201180","full_name":"qshuai/lru","owner":"qshuai","description":"An effective LRU implementation in Golang","archived":false,"fork":false,"pushed_at":"2022-08-19T10:31:27.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T11:48:12.263Z","etag":null,"topics":["effective","golang","lru-cache"],"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/qshuai.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-05-29T10:10:50.000Z","updated_at":"2022-08-19T10:30:06.000Z","dependencies_parsed_at":"2023-06-14T22:00:17.012Z","dependency_job_id":null,"html_url":"https://github.com/qshuai/lru","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/qshuai/lru","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qshuai%2Flru","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qshuai%2Flru/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qshuai%2Flru/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qshuai%2Flru/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qshuai","download_url":"https://codeload.github.com/qshuai/lru/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qshuai%2Flru/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28736373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T19:23:36.361Z","status":"ssl_error","status_checked_at":"2026-01-24T19:23:28.966Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["effective","golang","lru-cache"],"created_at":"2026-01-24T20:06:24.958Z","updated_at":"2026-01-24T20:06:25.565Z","avatar_url":"https://github.com/qshuai.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"lru\n===\n\n##### Usage:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/qshuai/lru\"\n)\n\ntype user struct {\n\tkey string\n\n\tscore int\n}\n\nfunc (u *user) GetKey() interface{} {\n\treturn u.key\n}\n\nfunc main() {\n  // set capacity to 3 for this cache as a sample\n  cache := lru.New(3, true)\n  // add 4 entries, the first entry will be removed automaticlly\n  cache.Add(\u0026user{\"Andy\", 23})\n  cache.Add(\u0026user{\"Tom\", 24})\n  cache.Add(\u0026user{\"Angel\", 25})\n  cache.Add(\u0026user{\"Nike\", 26})\n  fmt.Println(cache.Size(), cache.Existed(\"Andy\"), cache.Existed(\"Tom\"),\n    cache.Existed(\"Angel\"), cache.Existed(\"Nike\"))\n\n  // access the user Tom, the tom will be move to front\n  cache.Get(\"Tom\")\n  // now add a entry, the tail entry user named Angel will be removed\n  cache.Add(\u0026user{\"Jone\", 27})\n  fmt.Println(cache.Size(), cache.Existed(\"Tom\"), cache.Existed(\"Angel\"),\n    cache.Existed(\"Nike\"), cache.Existed(\"Jone\"))\n\n  // remove a enry by hand, we will discard this and update cache size\n  cache.Remove(\"Jone\")\n  fmt.Println(cache.Size(), cache.Existed(\"Tom\"), cache.Existed(\"Angel\"),\n    cache.Existed(\"Nike\"), cache.Existed(\"Jone\"))\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqshuai%2Flru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqshuai%2Flru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqshuai%2Flru/lists"}