{"id":15690138,"url":"https://github.com/justjavac/deno_ttl","last_synced_at":"2026-03-15T01:43:58.027Z","repository":{"id":43749718,"uuid":"392931979","full_name":"justjavac/deno_ttl","owner":"justjavac","description":"Simple in-memory TTL(Time To Live) cache for Deno.","archived":false,"fork":false,"pushed_at":"2022-09-13T04:21:11.000Z","size":10,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-26T05:41:22.998Z","etag":null,"topics":["deno","deno-module"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/justjavac.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":"2021-08-05T06:38:50.000Z","updated_at":"2023-01-26T11:55:38.000Z","dependencies_parsed_at":"2022-09-26T20:41:32.138Z","dependency_job_id":null,"html_url":"https://github.com/justjavac/deno_ttl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fdeno_ttl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fdeno_ttl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fdeno_ttl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fdeno_ttl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justjavac","download_url":"https://codeload.github.com/justjavac/deno_ttl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243042885,"owners_count":20226716,"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":["deno","deno-module"],"created_at":"2024-10-03T18:07:46.224Z","updated_at":"2026-03-15T01:43:52.984Z","avatar_url":"https://github.com/justjavac.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deno_ttl\n\n[![tag](https://img.shields.io/github/release/justjavac/deno_ttl)](https://github.com/justjavac/deno_ttl/releases)\n[![ci](https://github.com/justjavac/deno_ttl/actions/workflows/ci.yml/badge.svg)](https://github.com/justjavac/deno_ttl/actions/workflows/ci.yml)\n[![license](https://img.shields.io/github/license/justjavac/deno_ttl)](https://github.com/justjavac/deno_ttl/blob/master/LICENSE)\n[![](https://img.shields.io/badge/deno-v1.x-green.svg)](https://github.com/denoland/deno)\n\nSimple in-memory TTL(Time To Live) cache for Deno.\n\n## Usage\n\n```ts\nimport TTL from \"https://deno.land/x/ttl/mod.ts\";\n\nconst ttl = new TTL\u003cstring\u003e(10_000);\n\nttl.addEventListener(\"hit\", (event) =\u003e {\n  console.log(\"hit %s with value: %s\", event.key, event.val);\n});\n\nttl.set(\"foo\", \"bar\");\nttl.set(\"ping\", \"pong\", 20 * 1000);\nttl.set(\"user\", \"justjavac\", 30 * 1000);\n\nttl.get(\"foo\"); // \u003e 'bar'\nttl.get(\"user\"); // \u003e 'justjavac'\nttl.get(\"ping\"); // \u003e 'pong'\nttl.get(\"lol\"); // \u003e undefined\n\n// after 10 seconds\nttl.get(\"foo\"); // \u003e undefined\nttl.size; // \u003e 2\nttl.del(\"ping\"); // \u003e 'pong'\nttl.get(\"ping\"); // \u003e undefined\nttl.size; // \u003e 1\nttl.clear();\nttl.size; // \u003e 0\n```\n\n## Events\n\nUsage:\n\n```ts\nttl.addEventListener(\"set\", (event) =\u003e {\n  // event.key, event.val, event.expire\n});\n\nfunction onhit(event: TTLEvent\u003cstring\u003e) {\n  // event.key, event.val, event.expire\n}\n\nttl.addEventListener(\"hit\", onhit);\nttl.removeEventListener(\"hit\", onhit);\n```\n\n- `set` - The key has been added or changed.\n- `del` - The key has been removed manually or due to expiry.\n- `expired` - The key was expired.\n- `hit` - The key was found in TTL cache.\n- `miss` - The key was not found in TTL cache.\n- `drop` - The key was not been added.\n\n## License\n\n[deno_ttl](https://github.com/justjavac/deno_ttl) is released under the MIT\nLicense. See the bundled [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustjavac%2Fdeno_ttl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustjavac%2Fdeno_ttl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustjavac%2Fdeno_ttl/lists"}