{"id":22836610,"url":"https://github.com/goburrow/cache","last_synced_at":"2025-05-15T14:05:39.014Z","repository":{"id":43583703,"uuid":"71700663","full_name":"goburrow/cache","owner":"goburrow","description":"Mango Cache 🥭 - Partial implementation of Guava Cache in Go (golang).","archived":false,"fork":false,"pushed_at":"2022-10-14T19:33:07.000Z","size":201,"stargazers_count":594,"open_issues_count":10,"forks_count":46,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-07T18:09:39.973Z","etag":null,"topics":["cache","golang","lru","slru","tinylfu"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goburrow.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}},"created_at":"2016-10-23T12:13:03.000Z","updated_at":"2025-04-03T20:11:26.000Z","dependencies_parsed_at":"2022-07-12T18:19:10.914Z","dependency_job_id":null,"html_url":"https://github.com/goburrow/cache","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goburrow%2Fcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goburrow%2Fcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goburrow%2Fcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goburrow%2Fcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goburrow","download_url":"https://codeload.github.com/goburrow/cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254355334,"owners_count":22057354,"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":["cache","golang","lru","slru","tinylfu"],"created_at":"2024-12-12T23:11:54.244Z","updated_at":"2025-05-15T14:05:34.003Z","avatar_url":"https://github.com/goburrow.png","language":"Go","readme":"# Mango Cache\n[![GoDoc](https://godoc.org/github.com/goburrow/cache?status.svg)](https://godoc.org/github.com/goburrow/cache)\n![Go](https://github.com/goburrow/cache/workflows/Go/badge.svg)\n\nPartial implementations of [Guava Cache](https://github.com/google/guava) in Go.\n\nSupported cache replacement policies:\n\n- LRU\n- Segmented LRU (default)\n- TinyLFU (experimental)\n\nThe TinyLFU implementation is inspired by\n[Caffeine](https://github.com/ben-manes/caffeine) by Ben Manes and\n[go-tinylfu](https://github.com/dgryski/go-tinylfu) by Damian Gryski.\n\n## Download\n\n```\ngo get -u github.com/goburrow/cache\n```\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math/rand\"\n\t\"time\"\n\n\t\"github.com/goburrow/cache\"\n)\n\nfunc main() {\n\tload := func(k cache.Key) (cache.Value, error) {\n\t\ttime.Sleep(100 * time.Millisecond) // Slow task\n\t\treturn fmt.Sprintf(\"%d\", k), nil\n\t}\n\t// Create a loading cache\n\tc := cache.NewLoadingCache(load,\n\t\tcache.WithMaximumSize(100),                 // Limit number of entries in the cache.\n\t\tcache.WithExpireAfterAccess(1*time.Minute), // Expire entries after 1 minute since last accessed.\n\t\tcache.WithRefreshAfterWrite(2*time.Minute), // Expire entries after 2 minutes since last created.\n\t)\n\n\tgetTicker := time.Tick(100 * time.Millisecond)\n\treportTicker := time.Tick(5 * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase \u003c-getTicker:\n\t\t\t_, _ = c.Get(rand.Intn(200))\n\t\tcase \u003c-reportTicker:\n\t\t\tst := cache.Stats{}\n\t\t\tc.Stats(\u0026st)\n\t\t\tfmt.Printf(\"%+v\\n\", st)\n\t\t}\n\t}\n}\n```\n\n## Performance\n\nSee [traces](traces/) and [benchmark](https://github.com/goburrow/cache/wiki/Benchmark)\n\n![report](traces/report.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoburrow%2Fcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoburrow%2Fcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoburrow%2Fcache/lists"}