{"id":21571124,"url":"https://github.com/livepersoninc/cacherjs","last_synced_at":"2025-08-11T07:05:40.280Z","repository":{"id":32443110,"uuid":"36021385","full_name":"LivePersonInc/cacherjs","owner":"LivePersonInc","description":"JS TTL Cache Mechanism","archived":false,"fork":false,"pushed_at":"2022-01-20T01:41:46.000Z","size":62,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-08-09T02:49:37.305Z","etag":null,"topics":["cache","cacher","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LivePersonInc.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":"2015-05-21T15:36:04.000Z","updated_at":"2025-07-05T10:42:04.000Z","dependencies_parsed_at":"2022-09-01T06:00:32.743Z","dependency_job_id":null,"html_url":"https://github.com/LivePersonInc/cacherjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LivePersonInc/cacherjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LivePersonInc%2Fcacherjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LivePersonInc%2Fcacherjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LivePersonInc%2Fcacherjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LivePersonInc%2Fcacherjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LivePersonInc","download_url":"https://codeload.github.com/LivePersonInc/cacherjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LivePersonInc%2Fcacherjs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269844098,"owners_count":24484132,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","cacher","ttl","ttl-cache"],"created_at":"2024-11-24T11:14:57.798Z","updated_at":"2025-08-11T07:05:40.250Z","avatar_url":"https://github.com/LivePersonInc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"cacherjs\n========\n[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)\n[![Build Status](https://travis-ci.org/LivePersonInc/cacherjs.svg)](https://travis-ci.org/LivePersonInc/cacherjs)\n[![Test Coverage](https://codeclimate.com/github/LivePersonInc/cacherjs/badges/coverage.svg)](https://codeclimate.com/github/LivePersonInc/cacherjs/coverage)\n[![Code Climate](https://codeclimate.com/github/LivePersonInc/cacherjs/badges/gpa.svg)](https://codeclimate.com/github/LivePersonInc/cacherjs)\n[![npm version](https://badge.fury.io/js/cacherjs.svg)](http://badge.fury.io/js/cacherjs)\n[![Dependency Status](https://david-dm.org/LivePersonInc/cacherjs.svg?theme=shields.io)](https://david-dm.org/LivePersonInc/cacherjs)\n[![devDependency Status](https://david-dm.org/LivePersonInc/cacherjs/dev-status.svg?theme=shields.io)](https://david-dm.org/LivePersonInc/cacherjs#info=devDependencies)\n[![npm downloads](https://img.shields.io/npm/dm/cacherjs.svg)](https://img.shields.io/npm/dm/cacherjs.svg)\n[![NPM](https://nodei.co/npm/cacherjs.png)](https://nodei.co/npm/cacherjs/)\n\n\u003e JS TTL Cache Mechanism.\n\nThis is a UMD module that can be used as AMD module, native and NodeJS.\n\nGetting Started\n---------------\n\nRun `npm install cacherjs`\n\nOverview\n-------------\n\nA TTL cache mechanism with the following options at instance creation\n\n#### options.max\nType: `Number`\nDefault value: `0`\n\noptional max items in cache - 0 is unlimited\n\n#### options.maxStrategy\nType: `Cacher.MAX_STRATEGY`\nDefault value: `Cacher.MAX_STRATEGY.NO_ADD`\n\noptional strategy for max items (new items will not be added or closest ttl item should be removed)\n\n#### options.ttl\nType: `Number`\nDefault value: `0`\n\noptional TTL for each cache item - 0 is unlimited\n\n#### options.interval\nType: `Number`\nDefault value: `1000`\n\noptional interval for eviction loop in milliseconds\n\n#### options.ontimeout\nType: `Function`\nDefault value: `Empty function`\n\noptional global handler for timeout of items in cache - return false if you want the items to not be deleted after ttl, or object { ttl: number, callback: function } to update the TTL or callback\n\n#### options.onkickout\nType: `Function`\nDefault value: `Empty function`\n\noptional global handler for kick out (forced evict) of items in cache\n\nAPI\n----------\n### get (key, [optional]pop)\nWill get the value associated with the given `key`.\n`pop` is a boolean flag indicating whether to also pop/remove the item from cache.\n\n### set (key, value, [optional]ttl, [optional]callback)\nWill set `value` and associate it with the given `key`.\n`ttl` will override the time to live for the item inside the cache.\n`callback` will be called on item timeout - return false if you want the item to not be deleted after ttl, or object { ttl: number, callback: function } to update the TTL or callback\n\n### touch (key, [optional]ttl, [optional]callback)\nWill reset or update the `ttl` and/or update ontimeout callback for the given `key`.\n`ttl` will override the time to live for the item inside the cache.\n`callback` will override the initial handler to be called on item timeout - return false if you want the item to not be deleted after ttl, or object { ttl: number, callback: function } to update the TTL or callback\n\n### remove (key)\nWill remove `key` from cache.\n\n### removeAll\nWill clean the cache completely\n\nExample\n-----------\n```javascript\nvar Cacher = require(\"cacherjs\").Cacher;\nvar cache = new Cacher({\n    ttl: 180000,\n    interval: 30000,\n    max: 5000,\n    maxStrategy: Cacher.MAX_STRATEGY.CLOSEST_TTL\n});\nttlCache.set(\"key1\", \"someValue\");\nttlCache.get(\"key1\"); //\"someValue\"\n```\n\nLicense\n----------\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivepersoninc%2Fcacherjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivepersoninc%2Fcacherjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivepersoninc%2Fcacherjs/lists"}