{"id":18698222,"url":"https://github.com/mluby/lru-events","last_synced_at":"2025-11-08T17:30:30.678Z","repository":{"id":143887879,"uuid":"75918136","full_name":"mLuby/lru-events","owner":"mLuby","description":"LRU cache with event hooks","archived":false,"fork":false,"pushed_at":"2016-12-08T11:17:40.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-28T11:09:18.403Z","etag":null,"topics":["event-hooks","library","lru-cache"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/mLuby.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-08T08:25:53.000Z","updated_at":"2017-07-30T20:10:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"d0a2823b-44d4-4cf3-9bee-95212d4d5a2f","html_url":"https://github.com/mLuby/lru-events","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/mLuby%2Flru-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mLuby%2Flru-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mLuby%2Flru-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mLuby%2Flru-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mLuby","download_url":"https://codeload.github.com/mLuby/lru-events/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239558927,"owners_count":19658930,"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":["event-hooks","library","lru-cache"],"created_at":"2024-11-07T11:27:29.262Z","updated_at":"2025-11-08T17:30:30.633Z","avatar_url":"https://github.com/mLuby.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\nThis is a **Least-Recently Used cache** with **event hooks** and an optional **expiry** mode that removes keys if they aren't used within the specified time.\n\n# Install\n```shell\nnpm install --save lru-events\n```\n# Use\n```js\nvar makeLRU = require(\"lru-events\")\nvar lru = makeLRU()\nvar smallLru = makeLRU({max: 2})\nvar lruWithOptions = makeLRU({max: 2, expiryIfUnused: 5*60*1000})\n\nsmallLru.set(\"a\", \"A\")\nsmallLru.set(\"b\", \"B\")\nsmallLru.get(\"a\") // \"A\"\nsmallLru.set(\"c\", \"C\")\nsmallLru.get(\"a\") // \"A\"\nsmallLru.get(\"b\") // undefined\nsmallLru.get(\"c\") // \"C\"\n```\n# API\n```haskell\nclear :: () -\u003e () -- does not clear event handlers; event callback takes no args.\nget :: Key -\u003e Value\nlength :: () -\u003e Int -- event callback takes length.\non :: String -\u003e (Key -\u003e Value -\u003e ()) -- callbacks generally take Key and Value args.\npeek :: Key -\u003e Value -- does not change recently used order or expiry times\nremove :: Key -\u003e Value\nset :: Key -\u003e Value  -\u003e Value\n```\n\n# Defaults\n```js\noptions = {\n  max: 1000, // number of items before the least-recently used gets evicted.\n  expiryIfUnused: Infinity // in milliseconds\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmluby%2Flru-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmluby%2Flru-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmluby%2Flru-events/lists"}