{"id":22740472,"url":"https://github.com/next-boost/hybrid-disk-cache","last_synced_at":"2025-08-22T11:04:45.549Z","repository":{"id":41461854,"uuid":"256447232","full_name":"next-boost/hybrid-disk-cache","owner":"next-boost","description":"A hybrid disk cache library that utilized both the solid SQLite3 and file system.","archived":false,"fork":false,"pushed_at":"2025-04-10T01:32:13.000Z","size":350,"stargazers_count":23,"open_issues_count":6,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-16T23:23:38.053Z","etag":null,"topics":["cache","disk-cache","file-cache","javascript","sqlite3","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/next-boost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-04-17T08:34:03.000Z","updated_at":"2025-06-02T00:51:22.000Z","dependencies_parsed_at":"2024-06-18T18:20:39.279Z","dependency_job_id":"ed39ea38-c032-4fd1-bf0e-ce58cc0f480b","html_url":"https://github.com/next-boost/hybrid-disk-cache","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":0.02777777777777779,"last_synced_commit":"b62cb7db0de488dfafd28dc21976b957f36ba02d"},"previous_names":["rjyo/hybrid-disk-cache"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/next-boost/hybrid-disk-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/next-boost%2Fhybrid-disk-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/next-boost%2Fhybrid-disk-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/next-boost%2Fhybrid-disk-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/next-boost%2Fhybrid-disk-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/next-boost","download_url":"https://codeload.github.com/next-boost/hybrid-disk-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/next-boost%2Fhybrid-disk-cache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271628166,"owners_count":24792821,"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-22T02:00:08.480Z","response_time":65,"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","disk-cache","file-cache","javascript","sqlite3","typescript"],"created_at":"2024-12-10T23:08:59.084Z","updated_at":"2025-08-22T11:04:45.513Z","avatar_url":"https://github.com/next-boost.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Coverage Status](https://coveralls.io/repos/github/next-boost/hybrid-disk-cache/badge.svg?branch=master)](https://coveralls.io/github/next-boost/hybrid-disk-cache?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/270469eb02421e5c7547/maintainability)](https://codeclimate.com/github/next-boost/hybrid-disk-cache/maintainability)\n\n# hybrid-disk-cache\n\nA hybrid disk cache library that utilizes both a solid SQLite3 database and the file system.\n\n```bash\nyarn add @next-boost/hybrid-disk-cache\n```\n\nWhen the value is larger than 10 kilobytes, it will be written to the file system; otherwise, it's saved in the SQLite3 database.\n\nThe benefits of using this hybrid cache are:\n\n- Always uses the small footprint and high-performance SQLite3 index.\n- Uses the file system for larger files. No need to run `vacuum` for releasing space.\n\nAdditional features:\n\n- 100% test coverage\n- Pure TypeScript\n- Used in production with 300K keys\n- SQLite3's indices are always used when searching for a key (which is FAST)\n\nThis hybrid idea is inspired by [`python-diskcache`](https://github.com/grantjenks/python-diskcache). We use it in our Python production stack, and it works just as well as expected.\n\n## APIs\n\n```javascript\n// tbd, time before deletion: This is used to control how long a key\n// should remain in the cache after expired (ttl)\n// And `cache.purge` will delete all records with ttl + tbd \u003c now\nconst cache = new Cache({ path, ttl, tbd })\n\n// set. if ttl empty, use the cache's ttl\ncache.set(key, value)\n// set. will expire in 5 seconds\ncache.set(key, value, 5)\n\n// get\ncache.get(key, defaultValue)\n\n// del\ncache.del(key)\n\n// check cache availability and status\n// status in 'miss' | 'stale' | 'hit'\nconst status = cache.has(key)\n\n// if you want to serve even the stale value\nif (cache.has(key) !== 'miss') {\n  const value = cache.get(key)\n}\n\n// if you only want the unexpired one\nif (cache.has(key) === 'hit') {\n  const value = cache.get(key)\n}\n\n// delete all expired keys\ncache.purge()\n```\n\nCheck [`index.test.ts`](https://github.com/next-boost/hybrid-disk-cache/blob/master/test/index.test.ts) for examples.\n\n## Benchmarks\n\nWith a series of 10B ~ 500KB data writing and reading, here are the results on a Samsung 860 EVO SATA SSD:\n\nHere is the [benchmark source code](https://github.com/next-boost/hybrid-disk-cache/blob/master/src/bench.ts).\n\n```\n\u003e cache located at: /tmp/hdc\n\u003e generating bench data from 10B to 500000B\n\u003e starting 3000 x 15 writes\n  done: 69.34 μs/record.\n\u003e starting 3000 x 15 reads\n  done: 26.65 μs/record.\n```\n\n## License\n\nMIT. Copyright 2024, Rakuraku Jyo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnext-boost%2Fhybrid-disk-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnext-boost%2Fhybrid-disk-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnext-boost%2Fhybrid-disk-cache/lists"}