{"id":19782683,"url":"https://github.com/freddiehaddad/lrucache","last_synced_at":"2025-09-12T03:21:39.255Z","repository":{"id":222885555,"uuid":"758641516","full_name":"freddiehaddad/lrucache","owner":"freddiehaddad","description":"Least recently used (LRU) in-memory cache.","archived":false,"fork":false,"pushed_at":"2024-02-25T01:19:06.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-24T05:38:32.776Z","etag":null,"topics":["go","golang","leetcode","leetcode-go","leetcode-golang","leetcode-solution","lru-algorithm","lru-cache","lru-eviction","lru-implementation","lru-replacement-algorithm","lrucache"],"latest_commit_sha":null,"homepage":"https://leetcode.com/problems/lru-cache/?envType=study-plan-v2\u0026envId=top-interview-150","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/freddiehaddad.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":"2024-02-16T18:50:51.000Z","updated_at":"2024-02-16T19:33:30.000Z","dependencies_parsed_at":"2024-06-19T12:24:03.572Z","dependency_job_id":null,"html_url":"https://github.com/freddiehaddad/lrucache","commit_stats":null,"previous_names":["freddiehaddad/lrucache"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Flrucache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Flrucache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Flrucache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freddiehaddad%2Flrucache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freddiehaddad","download_url":"https://codeload.github.com/freddiehaddad/lrucache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241113911,"owners_count":19911987,"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":["go","golang","leetcode","leetcode-go","leetcode-golang","leetcode-solution","lru-algorithm","lru-cache","lru-eviction","lru-implementation","lru-replacement-algorithm","lrucache"],"created_at":"2024-11-12T06:05:51.151Z","updated_at":"2025-02-28T06:48:36.370Z","avatar_url":"https://github.com/freddiehaddad.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LRU Cache\n\nFully associative and in-memory least recently used (LRU) cache implementation.\n\nThe cache works by using two data structures:\n\n- Map\n- Linked List\n\nCache entries are fetched and stored in the map using the user-defined key.\n\nBookkeeping\n\nThe linked list is used for constant-time tracking of the least and most\nrecently used entries. The head of the list serves as the least recently used\nobject and the tail as most recently used.\n\nFor each Get operation that results in a cache hit, the element is moved to the\nend of the linked list to reflect it's most recently used status.\n\nFor Put operations, whether its a new entry being added or an update to an\nexisting element, the entry is moved to the tail of the list.\n\n## Demonstration\n\n```text\nLRUCache(3)\n\n+-----+-----+-----+\n|     |     |     |\n+-----+-----+-----+\n\nPut(1,1)\n\n+-----+-----+-----+\n|     |     | 1,1 |\n+-----+-----+-----+\n\nPut(2,2)\n\n+-----+-----+-----+\n|     | 1,1 | 2,2 |\n+-----+-----+-----+\n\nPut(3,3)\n\n+-----+-----+-----+\n| 1,1 | 2,2 | 3,3 |\n+-----+-----+-----+\n\nGet(1)\n\n+-----+-----+-----+\n| 2,2 | 3,3 | 1,1 |\n+-----+-----+-----+\n\nPut(3,4)\n\n+-----+-----+-----+\n| 2,2 | 1,1 | 3,4 |\n+-----+-----+-----+\n\nPut(5,5)\n\n+-----+-----+-----+\n| 1,1 | 3,4 | 5,5 |\n+-----+-----+-----+\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreddiehaddad%2Flrucache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreddiehaddad%2Flrucache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreddiehaddad%2Flrucache/lists"}