{"id":21954192,"url":"https://github.com/hirotoshioi/query-cache","last_synced_at":"2026-01-30T16:04:15.479Z","repository":{"id":265179288,"uuid":"895329818","full_name":"HirotoShioi/query-cache","owner":"HirotoShioi","description":"A lightweight, high-level caching library for both browsers and servers.","archived":false,"fork":false,"pushed_at":"2024-11-29T06:59:36.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-20T19:24:40.995Z","etag":null,"topics":["cache","nodejs"],"latest_commit_sha":null,"homepage":"","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/HirotoShioi.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}},"created_at":"2024-11-28T02:13:41.000Z","updated_at":"2024-11-29T06:59:39.000Z","dependencies_parsed_at":"2025-01-27T22:46:16.641Z","dependency_job_id":"b4a20cd5-d79c-4caf-8745-a1665f628007","html_url":"https://github.com/HirotoShioi/query-cache","commit_stats":null,"previous_names":["hirotoshioi/query-cache"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HirotoShioi/query-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HirotoShioi%2Fquery-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HirotoShioi%2Fquery-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HirotoShioi%2Fquery-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HirotoShioi%2Fquery-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HirotoShioi","download_url":"https://codeload.github.com/HirotoShioi/query-cache/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HirotoShioi%2Fquery-cache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28914947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T12:13:43.263Z","status":"ssl_error","status_checked_at":"2026-01-30T12:13:22.389Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","nodejs"],"created_at":"2024-11-29T07:17:07.442Z","updated_at":"2026-01-30T16:04:15.455Z","avatar_url":"https://github.com/HirotoShioi.png","language":"TypeScript","readme":"\n# query-cache\n\n`query-cache` is a lightweight library that provides simple yet powerful cache management.  \nInspired by the [`tanstack query`](https://github.com/TanStack/query), it offers a flexible and straightforward way to handle caching.\n\n## Features\n\n- **High-level and intuitive interface**  \n  Manage data fetching with just a cache key and a fetch function.\n\n  ```typescript\n  const data = await query.cache({ queryKey: ['key'], queryFn: async () =\u003e fetchData() });\n  ```\n\n- **Zero dependencies and lightweight**  \n  Built with no external dependencies, making it highly performant and lightweight.\n\n- **Compatible with both browser and server environments**  \n  Designed to work seamlessly in both Node.js and browser contexts.\n\n- **TypeScript support for type safety**  \n  Fully typed API to ensure safe and efficient development.\n\n- **Flexible cache management**  \n  Easily configure expiration times and stale data behavior.\n\n  ```typescript\n  await query.cache({ queryKey: ['key'], queryFn: fetchData, staleTime: 3000 });\n  ```\n\n---\n\n## Use Cases\n\n- **Caching API responses**  \n  Reduce network load and enable faster data retrieval.\n- **Unified data fetching management**  \n  Avoid duplicate fetches and streamline data handling.\n- **Efficient data storage for browser and server**  \n  Ideal for temporary data storage and cache management.\n\n---\n\n## Installation\n\nInstall using one of the following commands:\n\n```bash\nnpm install query-cache\n# or\nyarn add query-cache\n# or\npnpm add query-cache\n```\n\n---\n\n## Quick Start\n\nHere’s a basic example of how to use `query-cache`:\n\n### Creating a Simple Cache\n\n```typescript\nimport { QueryCache } from 'query-cache';\n\n// Create a QueryCache instance\nconst query = new QueryCache();\n\n// Fetch or retrieve cached data\nconst data = await query.cache({\n  queryKey: ['example-key'], // Cache key\n  queryFn: async () =\u003e {\n    // Your data-fetching logic\n    return 'Hello, query-cache!';\n  },\n});\n\nconsole.log(data); // 'Hello, query-cache!'\n```\n\n### Invalidating and Refetching Cache\n\nYou can invalidate cached data and refetch it if needed.\n\n```typescript\nconst query = new QueryCache();\n\n// Fetch and cache data\nawait query.cache({\n  queryKey: ['invalidate-example'],\n  queryFn: async () =\u003e 'First Fetch',\n});\n\n// Invalidate cache\nawait query.invalidateCache({\n  queryKey: ['invalidate-example'],\n  refetch: true, // Refetch after invalidation\n});\n```\n\n---\n\n## Tests\n\nThis project includes comprehensive tests to ensure reliability.\n\n```bash\nnpm run test\n```\n\n---\n\n## Contributing\n\n`query-cache` is open-source, and contributions are welcome! Please follow these guidelines when submitting a pull request:\n\n1. Follow the coding style (Prettier, ESLint).\n2. Add necessary test cases.\n\n---\n\n## License\n\nMIT License © Hiroto Shioi\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirotoshioi%2Fquery-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirotoshioi%2Fquery-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirotoshioi%2Fquery-cache/lists"}