{"id":24708126,"url":"https://github.com/rutaka-n/plrucache","last_synced_at":"2025-03-22T06:13:37.121Z","repository":{"id":212990929,"uuid":"732758417","full_name":"rutaka-n/plrucache","owner":"rutaka-n","description":"(p)LRU in memory cache","archived":false,"fork":false,"pushed_at":"2024-04-01T18:10:34.000Z","size":17,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T06:32:18.227Z","etag":null,"topics":["cache","lru-algorithm","lru-cache","memory"],"latest_commit_sha":null,"homepage":"","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/rutaka-n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-12-17T18:26:17.000Z","updated_at":"2024-04-05T22:52:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f8cbd7d-e71d-4f1b-89fb-9e2e03eadebc","html_url":"https://github.com/rutaka-n/plrucache","commit_stats":null,"previous_names":["rutaka-n/plrucache"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rutaka-n%2Fplrucache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rutaka-n%2Fplrucache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rutaka-n%2Fplrucache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rutaka-n%2Fplrucache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rutaka-n","download_url":"https://codeload.github.com/rutaka-n/plrucache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244913330,"owners_count":20530817,"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","lru-algorithm","lru-cache","memory"],"created_at":"2025-01-27T06:27:50.222Z","updated_at":"2025-03-22T06:13:37.099Z","avatar_url":"https://github.com/rutaka-n.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/rutaka-n/plrucache.svg)](https://pkg.go.dev/github.com/rutaka-n/plrucache)\n\n# pLRUCache\n(pseudo) LRU cache is a library that implements in-memory (p)LRU cache with focus on efficient memory utilization.\nIt uses static queues to track expiration time and least recently used items in preallocated memory, so it has minimal\nmemory footprint. This approach helps to avoid high memory consumtion on the peak load.\nIt is pseudo LRU, since it relies on `time.Time` to identify least recently used items, so in theory it might drop\nnot actually least recently used item, but almost least recently used one.\nIt uses `sync.Mutex` to deal with concurrent read/write operations.\n\n## Install\n```sh\ngo get github.com/rutaka-n/plrucache\n```\n## Usage\n```sh\npackage main\n\nimport (\n\t\"fmt\"\n\tlru \"github.com/rutaka-n/plrucache\"\n\t\"time\"\n)\n\ntype item struct {\n\tid  int64\n\tval string\n}\n\nfunc main() {\n\tcacheSize := 128\n\texpirationTime := 300 * time.Second\n\tcache := lru.New[string, item](cacheSize, expirationTime)\n\n\tkey := \"k1\"\n\tvalue := item{1, \"hello, world\"}\n\tcache.Set(key, value)\n\n\tres, ok := cache.Get(key)\n    if !ok {\n        panic(\"item is not in cache\")\n    }\n\tfmt.Printf(\"%+v\", res)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frutaka-n%2Fplrucache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frutaka-n%2Fplrucache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frutaka-n%2Fplrucache/lists"}