{"id":16767390,"url":"https://github.com/vardius/lru-cache","last_synced_at":"2025-03-16T13:13:35.032Z","repository":{"id":57608339,"uuid":"210103826","full_name":"vardius/lru-cache","owner":"vardius","description":"A Least Recently Used (LRU) Cache organizes items in order of use, allowing you to quickly identify which item hasn't been used for the longest amount of time.","archived":false,"fork":false,"pushed_at":"2020-09-16T13:28:31.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-23T00:43:11.449Z","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/vardius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-22T06:53:01.000Z","updated_at":"2020-09-16T13:28:33.000Z","dependencies_parsed_at":"2022-09-03T10:22:23.967Z","dependency_job_id":null,"html_url":"https://github.com/vardius/lru-cache","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/vardius%2Flru-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Flru-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Flru-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Flru-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vardius","download_url":"https://codeload.github.com/vardius/lru-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871912,"owners_count":20361380,"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-10-13T06:09:02.873Z","updated_at":"2025-03-16T13:13:35.013Z","avatar_url":"https://github.com/vardius.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"🗃️ lru-cache\n================\n[![Build Status](https://travis-ci.org/vardius/lru-cache.svg?branch=master)](https://travis-ci.org/vardius/lru-cache)\n[![Go Report Card](https://goreportcard.com/badge/github.com/vardius/lru-cache)](https://goreportcard.com/report/github.com/vardius/lru-cache)\n[![codecov](https://codecov.io/gh/vardius/lru-cache/branch/master/graph/badge.svg)](https://codecov.io/gh/vardius/lru-cache)\n[![](https://godoc.org/github.com/vardius/lru-cache?status.svg)](https://pkg.go.dev/github.com/vardius/lru-cache)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/vardius/lru-cache/blob/master/LICENSE.md)\n\n\u003cimg align=\"right\" height=\"180px\" src=\"https://github.com/vardius/gorouter/blob/master/website/src/static/img/logo.png?raw=true\" alt=\"logo\" /\u003e\n\nGo simple LRU in memory cache\n\nA Least Recently Used (LRU) Cache organizes items in order of use, allowing you to quickly identify which item hasn't been used for the longest amount of time.\n\n* Strengths:\n\t- Super fast accesses. LRU caches store items in order from most-recently used to least-recently used. That means both can be accessed in O(1)O(1) time.\n\t- Super fast updates. Each time an item is accessed, updating the cache takes O(1) time.\n\n📖 ABOUT\n==================================================\nContributors:\n\n* [Rafał Lorenz](http://rafallorenz.com)\n\nWant to contribute ? Feel free to send pull requests!\n\nHave problems, bugs, feature ideas?\nWe are using the github [issue tracker](https://github.com/vardius/lru-cache/issues) to manage them.\n\n## 📚 Documentation\n\nFor __examples__ **visit [godoc#pkg-examples](http://godoc.org/github.com/vardius/lru-cache#pkg-examples)**\n\nFor **GoDoc** reference, **visit [pkg.go.dev](https://pkg.go.dev/github.com/vardius/lru-cache)**\n\n🚏 HOW TO USE\n==================================================\n\n## 🚅 Benchmark\n**CPU: 3,3 GHz Intel Core i7**\n\n**RAM: 16 GB 2133 MHz LPDDR3**\n\n```bash\n➜  lru-cache git:(master) go test -bench=. -cpu=4 -benchmem\ngoos: darwin\ngoarch: amd64\npkg: github.com/vardius/lru-cache\nBenchmarkRead-4         23051137                50.1 ns/op             0 B/op          0 allocs/op\nBenchmarkWrite-4        23097510                51.8 ns/op             0 B/op          0 allocs/op\nPASS\nok  \tgithub.com/vardius/lru-cache\t2.713s\n```\n\n## 🏫 Basic example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n    lrucache \"github.com/vardius/lru-cache\"\n)\n\nfunc main() {\n\tc, err := lrucache.New(\"example-cache\", 10*lrucache.MB)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn\n\t}\n\n\titem, err := c.Get(\"test\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn\n\t}\n\n\tif item == nil {\n\t\tif err = c.Set(\"test\", []byte(\"value\")); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tgot, err := c.Get(\"test\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn\n\t}\n\n\tfmt.Println(string(got))\n\n\t// Output:\n\t// value\n}\n```\n\n📜 [License](LICENSE.md)\n-------\n\nThis package is released under the MIT license. See the complete license in the package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvardius%2Flru-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvardius%2Flru-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvardius%2Flru-cache/lists"}