{"id":27265891,"url":"https://github.com/sgtlambda/johnnycache","last_synced_at":"2025-04-11T08:39:26.419Z","repository":{"id":44218626,"uuid":"48286134","full_name":"sgtlambda/johnnycache","owner":"sgtlambda","description":"Super simple file operation cache","archived":false,"fork":false,"pushed_at":"2022-12-09T08:03:34.000Z","size":526,"stargazers_count":3,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-05T14:35:40.724Z","etag":null,"topics":[],"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/sgtlambda.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-12-19T15:05:30.000Z","updated_at":"2023-05-13T01:28:14.000Z","dependencies_parsed_at":"2023-01-25T12:20:14.028Z","dependency_job_id":null,"html_url":"https://github.com/sgtlambda/johnnycache","commit_stats":null,"previous_names":[],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtlambda%2Fjohnnycache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtlambda%2Fjohnnycache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtlambda%2Fjohnnycache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgtlambda%2Fjohnnycache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgtlambda","download_url":"https://codeload.github.com/sgtlambda/johnnycache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248362226,"owners_count":21091072,"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":"2025-04-11T08:39:25.747Z","updated_at":"2025-04-11T08:39:26.388Z","avatar_url":"https://github.com/sgtlambda.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# johnnycache\n\n\u003e Super simple file operation cache\n\n[![Build Status][travis-image]][travis-url]\n[![Code Coverage][coveralls-image]][coveralls-url]\n[![NPM Version][npm-image]][npm-url]\n\n\n## Install\n\n```\n$ yarn add johnnycache@next\n```\n\n\n## Usage\n\n```js\nconst Cache = require('johnnycache');\nconst exec  = require('execa').shell;\n\nconst cache = new Cache();\n\nconst npmInstall = new Cache.Intent(() =\u003e exec('npm install'), {\n    input:  ['package.json'],\n    output: ['node_modules'],\n});\n\nawait cache.run(npmInstall);\n\n```\n\n## API\n\n### Cache([options])\n\nConstructor\n\n#### options\n\n##### workingDirectory\n\nType: `string`\n\nDefault: `process.cwd()`\n\nBase path for cache `input` and `output` options.\n\n##### workspace\n\nType: `string`  \n\nDefault: `path.join(process.cwd(), '.johnny')`\n\nThe path to the cache folder (will be [created](https://github.com/sindresorhus/make-dir) if it doesn't exist)\n\n##### maxSize\n\nType: `string`\n\nDefault: `512mb`\n\nThe maximum size of the cache folder. Once this is exceeded, existing cached operation results will be intelligently purged based on the time of creation, the filesize, the time it originally took to run the operation, and the degree of redundancy. \n\u003e Note: Expired cache results (based on `ttl`) will always be purged regardless of whether the max cache size is hit.\n\n### new Cache.Intent(run, options)\n\nCreate a new operation intent.\n\n#### run\n\nType: `function`\n\nA function that returns a promise for the file operation's completion. The promise will resolve into an instance of either `SavedToCache`, `RestoredFromCache`.\n\n#### options\n\n##### input\n\nType: `string|string[]` (optional)\n\nA glob/directory or a mixed array of globs/directories that indicate the files of which the hash should be calculated to check whether there is a cached version of the operation\n\n##### output\n\nType: `string|string[]`\n\nA glob/directory or a mixed array of globs/directories that indicate the files that are produced as a result of the operation\n\n##### ttl\n\nType: `number`\n\nTtl (time-to-live) in milliseconds. If none given, the cache will not expire and will only be purged automatically if the total cache size exceeds the configured maximum.\n\n##### action\n\nType: `string`\n\nDefault: Automatically generated string based on `input` and `output` arguments\n\nIdentifier for the operation\n\n##### compress\n\nType: `boolean`\n\nDefault: `false`\n\nWhether to compress cached files - if enabled, a `.tar.gz` file will be generated instead of a `.tar` file.\n\n### Cache.run(intent)\n\nRun the operation, or restore cached results for the operation.\n\n## License\n\nMIT © [sgtlambda](http://github.com/sgtlambda)\n\n[![dependency Status][david-image]][david-url]\n[![devDependency Status][david-dev-image]][david-dev-url]\n\n[travis-image]: https://img.shields.io/travis/sgtlambda/johnnycache.svg?style=flat-square\n[travis-url]: https://travis-ci.org/sgtlambda/johnnycache\n\n[codeclimate-image]: https://img.shields.io/codeclimate/github/sgtlambda/johnnycache.svg?style=flat-square\n[codeclimate-url]: https://codeclimate.com/github/sgtlambda/johnnycache\n\n[david-image]: https://img.shields.io/david/sgtlambda/johnnycache.svg?style=flat-square\n[david-url]: https://david-dm.org/sgtlambda/johnnycache\n\n[david-dev-image]: https://img.shields.io/david/dev/sgtlambda/johnnycache.svg?style=flat-square\n[david-dev-url]: https://david-dm.org/sgtlambda/johnnycache#info=devDependencies\n\n[coveralls-image]: https://img.shields.io/coveralls/sgtlambda/johnnycache.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/sgtlambda/johnnycache\n\n[npm-image]: https://img.shields.io/npm/v/johnnycache.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/johnnycache\n\n[node-image]: https://img.shields.io/badge/node-%3E=_v7.6-lightgrey.svg?style=flat-square\n[node-url]: https://nodejs.org/en/blog/release/v7.6.0/\n\n---\n\nIf I could start again \n\nA million miles away \n\nI would keep myself \n\nI would find a way\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgtlambda%2Fjohnnycache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgtlambda%2Fjohnnycache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgtlambda%2Fjohnnycache/lists"}