{"id":17862149,"url":"https://github.com/jtblin/sync-cache","last_synced_at":"2025-04-02T21:14:09.728Z","repository":{"id":15398967,"uuid":"18130836","full_name":"jtblin/sync-cache","owner":"jtblin","description":"NodeJS cache for synchronous modules e.g. using Fibers based on Isaac's AsyncCache","archived":false,"fork":false,"pushed_at":"2014-03-26T08:11:58.000Z","size":116,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-09T16:37:04.567Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jtblin.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":"2014-03-26T08:05:15.000Z","updated_at":"2014-03-26T08:11:58.000Z","dependencies_parsed_at":"2022-08-25T13:30:54.896Z","dependency_job_id":null,"html_url":"https://github.com/jtblin/sync-cache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtblin%2Fsync-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtblin%2Fsync-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtblin%2Fsync-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtblin%2Fsync-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtblin","download_url":"https://codeload.github.com/jtblin/sync-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246892847,"owners_count":20850850,"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-10-28T08:50:44.909Z","updated_at":"2025-04-02T21:14:09.708Z","avatar_url":"https://github.com/jtblin.png","language":"JavaScript","readme":"# sync-cache\n\nCache for synchronous modules e.g. using Fibers based on [Isaac's AsyncCache](https://github.com/isaacs/async-cache).\nBy default use [lru-cache](https://github.com/isaacs/node-lru-cache) but can be passed any store that follows a simple api.\n\n## Usage\n\n    npm install sync-cache --save\n\n```js\nvar SyncCache = require('sync-cache');\nvar client = require('./my-sync-module');\nvar cache = new SyncCache({ max: 1000, maxAge: 1000*60*60, load: client.find });\n\n// ...\n\nvar value = cache.get(params);\n// Do something with value\n```\n\n## Options\n\n- `load` function to execute when no item is found in the cache\n- `max` number of items to cache (passed to `lru-cache` or configured cache store), defaults **Infinity**\n- `maxAge` maximum number of milliseconds to keep items, defaults **null**\n- `stale` boolean to indicate if cache should return stale items (`lru-cache`),default **false**\n- `store` cache store object, default **lru-cache**\n\n## API\n\n### get (key)\n\nReturns an item from the cache. If the item is not found, call the load handler to retrieve the item and\nsave the item in the cache.\n\n### set (key, value)\n\nSave the value in the cache for key.\n\n### del (key)\n\nDelete an item from the cache.\n\n### reset ()\n\nRemove all items from the cache.\n**Note** support varies with underlying cache stores, e.g. not possible with `sync-memcached-store`.\n\n### has (key)\n\nCheck if a key exists without returning the value.\n**Note** support varies with underlying cache stores, e.g. it is the same as a `get` with `sync-memcached-store`.\n\n### peek (key)\n\nCalls underlying cache store `peek` method.\n**Note** support varies with underlying cache stores, e.g. not possible with `sync-memcached-store`.\n\n## Cache stores\n\nTo create a new cache store for SyncCache, it must support the same API i.e. get, has, set, del, reset, has, peek.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtblin%2Fsync-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtblin%2Fsync-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtblin%2Fsync-cache/lists"}