{"id":21019414,"url":"https://github.com/ceramicnetwork/least-recent","last_synced_at":"2025-08-04T23:11:26.511Z","repository":{"id":188283248,"uuid":"678500967","full_name":"ceramicnetwork/least-recent","owner":"ceramicnetwork","description":"A cache object that deletes the least-recently-used items","archived":false,"fork":false,"pushed_at":"2023-08-14T17:43:50.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-07T08:36:36.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/ceramicnetwork.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}},"created_at":"2023-08-14T17:40:29.000Z","updated_at":"2023-08-14T17:42:01.000Z","dependencies_parsed_at":"2023-08-14T18:24:11.639Z","dependency_job_id":null,"html_url":"https://github.com/ceramicnetwork/least-recent","commit_stats":null,"previous_names":["ceramicnetwork/least-recent"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceramicnetwork%2Fleast-recent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceramicnetwork%2Fleast-recent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceramicnetwork%2Fleast-recent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceramicnetwork%2Fleast-recent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceramicnetwork","download_url":"https://codeload.github.com/ceramicnetwork/least-recent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243447641,"owners_count":20292455,"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-11-19T10:31:54.830Z","updated_at":"2025-03-13T17:24:41.405Z","avatar_url":"https://github.com/ceramicnetwork.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# most-recent\n\nProvides an implementation of LRUCache. Effectively a fork of [LRUCache from Mnemonist](https://github.com/Yomguithereal/mnemonist/tree/master) with one additional feature.\n\n`LRU` standing for _least recently used_, can be seen as a a fixed-capacity key-value store that will evict infrequent items when full and setting new keys.\n\nFor instance, if one creates a `LRUCache` with a capacity of `1000` and one inserts a thousand-and-first key, the cache will forget its least recently used key-value pair in order not to overflow the allocated memory.\n\nThis structure is very useful to cache the result of costly operations when one cannot afford to keep every result in memory and only want to keep the most frequent ones.\n\nFor more information, you can check [this](\u003chttps://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)\u003e) Wikipedia page.\n\n```typescript\nimport { LRUCache } from \"most-recent\";\n```\n\n## Usage\n\nThe `LRUCache` takes a single argument to create: the desired capacity. You could also provide types for keys and values.\n\n```typescript\nconst cache = new LRUCache(1000);\nconst stringCache = new LRUCache\u003cstring, string\u003e(1000);\n```\n\nFor available methods, please see [Mnemonist LRUCache documentation](https://yomguithereal.github.io/mnemonist/lru-cachehttps://yomguithereal.github.io/mnemonist/lru-cache)\n\nThe only difference from Mnemonist, is we emit an event (using [`nanoevents`](https://www.npmjs.com/package/nanoevents)) if an entry gets evicted.\n\n```typescript\nimport { LRUCache } from \"most-recent\";\nconst cache = new LRUCache(1000);\ncache.on(\"evicted\", (key, value) =\u003e {\n  console.log(\"evicted entry\", key, value);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceramicnetwork%2Fleast-recent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceramicnetwork%2Fleast-recent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceramicnetwork%2Fleast-recent/lists"}