{"id":17122056,"url":"https://github.com/ruffrey/filru","last_synced_at":"2025-07-08T06:36:25.691Z","repository":{"id":57235981,"uuid":"108653305","full_name":"ruffrey/filru","owner":"ruffrey","description":"Disk-based (no RAM) least-recently-used cache for Node.js","archived":false,"fork":false,"pushed_at":"2023-04-19T09:10:53.000Z","size":65,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T22:43:10.167Z","etag":null,"topics":["http-cache","lru-cache","nodejs"],"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/ruffrey.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-28T13:54:05.000Z","updated_at":"2023-08-18T18:34:45.000Z","dependencies_parsed_at":"2025-04-13T05:01:40.870Z","dependency_job_id":"260eb3a1-3fb1-4780-805a-c9dbbc22ac03","html_url":"https://github.com/ruffrey/filru","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ruffrey/filru","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Ffilru","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Ffilru/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Ffilru/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Ffilru/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruffrey","download_url":"https://codeload.github.com/ruffrey/filru/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruffrey%2Ffilru/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263861777,"owners_count":23521346,"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":["http-cache","lru-cache","nodejs"],"created_at":"2024-10-14T18:06:21.986Z","updated_at":"2025-07-08T06:36:25.657Z","avatar_url":"https://github.com/ruffrey.png","language":"JavaScript","readme":"# filru \u0026nbsp;\u0026nbsp; [![Build Status](https://travis-ci.org/ruffrey/filru.svg?branch=master)](https://travis-ci.org/ruffrey/filru)\n\nA pure-disk based least-recently-used (LRU) cache.\n\nNothing is kept in memory. This has the benefit of persisting across application restarts,\nand not taking up any RAM.\n\nThe cache is constrained by size (bytes), and optionally by file age.\n\n## Use Cases\n\nfilru is much slower than an in-memory cache, so use cases are:\n\n- a simplistic caching layer for frequent HTTP requests, since OS file system caching is much\nfaster than doing a network request\n- caching the results of CPU-intensive operations\n- caching slow operations across multiple network requests\n- caching large items\n\n## Usage\n\nNode.js \u003e= version 6\n\n```\nnpm install filru\n```\n\n\n```javascript\nconst Filru = require('filru');\nconst require('request-promise-native'); // optional for loading async when not in cache\nconst handleErr = (err) =\u003e {\n  throw err;\n};\n\nconst maxBytes = 50 * 1024 * 1024; // 50 megabytes\nconst maxAge = 24 * 60 * 60 * 1000; // 1 day\nconst hashSeed = 'cache4gold'; // optional, random seed string\nconst pruneInterval = 1000 * 60 * 60; // optional, defaults to 1 hour\nconst f = new Filru({ dir: '/tmp/filru', maxBytes, maxAge, hashSeed, pruneInterval });\n\n// optionally add a load function for when an object\n// is not found in the cache\nf.load = function customLoad(key) {\n  // Custom async load function must return a promise.\n  return request.get('https://my-site.com/' + key);\n};\n\nf.start()\n  .then(() =\u003e {\n    // fill the cache\n    f.set('jimmy.txt', 'yo').catch(handleErr);\n    f.get('jimmy.txt')\n        .then((buffer) =\u003e {\n          console.log('got jimmy:', buffer.toString('utf8')); // \"yo\"\n        })\n        .catch(handleErr);\n    // stop cleanup job\n    f.stop();\n  })\n  .catch(err =\u003e {\n    throw err;\n  });\n```\n\n## Tests\n\n```\nnpm test\n```\n\n## Debugging\n\nRun your application with `DEBUG=filru*`\n\n## License\n\nMIT\n\nSee LICENSE file in the root of this directory.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruffrey%2Ffilru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruffrey%2Ffilru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruffrey%2Ffilru/lists"}