{"id":19448264,"url":"https://github.com/csbun/lazy-cache","last_synced_at":"2026-05-16T19:32:17.778Z","repository":{"id":57289822,"uuid":"38596110","full_name":"csbun/lazy-cache","owner":"csbun","description":"lazy cache, automatic reset cache asynchronously when expired","archived":false,"fork":false,"pushed_at":"2015-07-21T06:33:00.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T07:05:06.122Z","etag":null,"topics":[],"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/csbun.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-07-06T03:40:21.000Z","updated_at":"2015-07-06T03:57:35.000Z","dependencies_parsed_at":"2022-08-28T10:50:33.241Z","dependency_job_id":null,"html_url":"https://github.com/csbun/lazy-cache","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/csbun%2Flazy-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csbun%2Flazy-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csbun%2Flazy-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csbun%2Flazy-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csbun","download_url":"https://codeload.github.com/csbun/lazy-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240636664,"owners_count":19832922,"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-10T16:25:34.242Z","updated_at":"2026-05-16T19:32:17.749Z","avatar_url":"https://github.com/csbun.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lazycache\n\nlazy inmemory cache for node, automatic reset cache asynchronously when expired\n\n[![NPM](https://nodei.co/npm/lazycache.png?compact=true)](https://nodei.co/npm/lazycache/)\n\n[![Build Status](https://travis-ci.org/csbun/lazy-cache.svg?branch=master)](https://travis-ci.org/csbun/lazy-cache)\n[![Coverage Status](https://coveralls.io/repos/csbun/lazy-cache/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/csbun/lazy-cache?branch=master)\n\n## Install\n\n```\nnpm i lazycache --save\n```\n\n## Usage\n\n### lazyCache()\n\nUse the factory method to init a cache object:\n\n```javascript\nvar defaultCacheTime = 300000; // 300000 ms = 5 min\nvar cache = require('lazyCache')(defaultCacheTime);\n```\n\nif `defaultCacheTime \u003c 0`, a `noCache` object will return, which offer the same API but do __NOT__ cache anything.\n\n### cache.get(key)\n\nGet value from cache\n\n- key: cache key\n\n```javascript\ncache.set('key', 'my cache value');\n```\n\n### cache.set(key, val [, cacheTime] [, reseter])\n\nSet value into cache\n\n- key: cache key\n- val: cache value\n- cacheTime: cache time (ms)\n- reseter: a function which reset the `cache value`\n\n```javascript\nvar reseter = function (cb) {\n    // async\n    setTimeout(function () {\n        cb(null, 'new value'); // `null` for NO error\n    }, 30);\n};\ncache.set('key', 'initial value', reseter)\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsbun%2Flazy-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsbun%2Flazy-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsbun%2Flazy-cache/lists"}