{"id":21655877,"url":"https://github.com/mrhooray/ttl","last_synced_at":"2025-10-19T20:43:58.204Z","repository":{"id":22176511,"uuid":"25508393","full_name":"mrhooray/ttl","owner":"mrhooray","description":"Simple in-memory cache for JavaScript","archived":false,"fork":false,"pushed_at":"2019-11-01T08:43:00.000Z","size":9,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-25T17:22:40.404Z","etag":null,"topics":["cache","in-memory","javascript","ttl","ttl-cache"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/mrhooray.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}},"created_at":"2014-10-21T07:25:00.000Z","updated_at":"2022-06-18T06:04:07.000Z","dependencies_parsed_at":"2022-07-24T23:02:07.892Z","dependency_job_id":null,"html_url":"https://github.com/mrhooray/ttl","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrhooray%2Fttl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrhooray%2Fttl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrhooray%2Fttl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrhooray%2Fttl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrhooray","download_url":"https://codeload.github.com/mrhooray/ttl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248482842,"owners_count":21111391,"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","in-memory","javascript","ttl","ttl-cache"],"created_at":"2024-11-25T08:37:32.813Z","updated_at":"2025-10-19T20:43:53.166Z","avatar_url":"https://github.com/mrhooray.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ttl [![Build Status](https://travis-ci.org/mrhooray/ttl.svg?branch=master)](https://travis-ci.org/mrhooray/ttl)\n\u003e Simple in-memory cache for JavaScript\n\n## Installation\n```shell\n$ npm install ttl --save\n```\n\n## Usage\n```js\nvar Cache = require('ttl');\nvar cache = new Cache({\n    ttl: 10 * 1000,\n    capacity: 3\n});\n\ncache.on('put', function(key, val, ttl) { });\ncache.on('del', function(key, val) { });\ncache.on('drop', function(key, val, ttl) { });\ncache.on('hit', function(key, val) { });\ncache.on('miss', function(key) { });\n\ncache.put('foo', 'bar');\ncache.put('ping', 'pong', 20 * 1000);\ncache.put('yo', 'yo', 30 * 1000);\ncache.put('whats', 'up'); // emit 'drop' event\n\ncache.get('foo');     // \u003e 'bar'\ncache.get('yo');      // \u003e 'yo'\ncache.get('ping');    // \u003e 'pong'\ncache.get('lol');     // \u003e undefined\n\n// after 10 seconds\ncache.get('foo');     // \u003e undefined\ncache.size();         // \u003e 2\ncache.del('ping')     // \u003e 'pong'\ncache.get('ping');    // \u003e undefined\ncache.size();         // \u003e 1\ncache.clear();\ncache.size();         // \u003e 0\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrhooray%2Fttl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrhooray%2Fttl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrhooray%2Fttl/lists"}