{"id":13630513,"url":"https://github.com/tidwall/tinylru","last_synced_at":"2025-04-12T20:42:10.993Z","repository":{"id":43149780,"uuid":"239373934","full_name":"tidwall/tinylru","owner":"tidwall","description":"A fast little LRU cache for Go","archived":false,"fork":false,"pushed_at":"2023-05-22T11:31:07.000Z","size":36,"stargazers_count":168,"open_issues_count":1,"forks_count":21,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-03T23:11:53.553Z","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/tidwall.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}},"created_at":"2020-02-09T21:03:40.000Z","updated_at":"2025-04-02T23:50:48.000Z","dependencies_parsed_at":"2024-01-13T23:06:52.955Z","dependency_job_id":"6f8e3740-7fc6-4ffd-9616-ffa4d2a5b725","html_url":"https://github.com/tidwall/tinylru","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidwall%2Ftinylru","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidwall%2Ftinylru/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidwall%2Ftinylru/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidwall%2Ftinylru/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidwall","download_url":"https://codeload.github.com/tidwall/tinylru/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631668,"owners_count":21136554,"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-08-01T22:01:45.565Z","updated_at":"2025-04-12T20:42:10.963Z","avatar_url":"https://github.com/tidwall.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Open source library"],"sub_categories":["算法","Algorithm"],"readme":"# `tinylru`\n\n[![GoDoc](https://godoc.org/github.com/tidwall/tinylru?status.svg)](https://godoc.org/github.com/tidwall/tinylru)\n\nA fast little LRU cache. \n\n## Getting Started\n\n### Installing\n\nTo start using `tinylru`, install Go and run go get:\n\n```\n$ go get -u github.com/tidwall/tinylru\n```\n\nThis will retrieve the library.\n\n### Usage\n\nNote: this package also has a non-generic `tinylru.LRU` implementation.\n\n```go\n// Create an LRU cache\nvar cache tinylru.LRUG[string, string]\n\n// Set the cache size. This is the maximum number of items that the cache can\n// hold before evicting old items. The default size is 256.\ncache.Resize(1024)\n\n// Set a key. Returns the previous value and ok if a previous value exists.\nprev, ok := cache.Set(\"hello\", \"world\")\n\n// Get a key. Returns the value and ok if the value exists.\nvalue, ok := cache.Get(\"hello\")\n\n// Delete a key. Returns the deleted value and ok if a previous value exists.\nprev, ok := cache.Delete(\"hello\")\n```\n\nA `Set` function may evict old items when adding a new item while LRU is at\ncapacity. If you want to know what was evicted then use the `SetEvicted`\nfunction.\n\n```go\n// Set a key and return the evicted item, if any.\nprev, ok, evictedKey, evictedValue, evicted := cache.SetEvicted(\"hello\", \"jello\")\n```\n\n### Contact\n\nJosh Baker [@tidwall](https://twitter.com/tidwall)\n\n### License\n\n`tinylru` source code is available under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidwall%2Ftinylru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidwall%2Ftinylru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidwall%2Ftinylru/lists"}