{"id":22908588,"url":"https://github.com/yxx4c/cache-utils","last_synced_at":"2025-06-22T19:07:58.788Z","repository":{"id":215558517,"uuid":"739215821","full_name":"yxx4c/cache-utils","owner":"yxx4c","description":"Simple JavaScript utility for straightforward cache management","archived":false,"fork":false,"pushed_at":"2024-08-20T20:00:04.000Z","size":91,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T19:07:26.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.com/@yxx4c/cache-utils","language":"TypeScript","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/yxx4c.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}},"created_at":"2024-01-05T03:23:35.000Z","updated_at":"2024-08-20T20:00:08.000Z","dependencies_parsed_at":"2024-01-05T05:34:31.584Z","dependency_job_id":"b32a321c-d036-46c9-b923-d11a6a79d8f5","html_url":"https://github.com/yxx4c/cache-utils","commit_stats":null,"previous_names":["yxx4c/cache-utils"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yxx4c/cache-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxx4c%2Fcache-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxx4c%2Fcache-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxx4c%2Fcache-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxx4c%2Fcache-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yxx4c","download_url":"https://codeload.github.com/yxx4c/cache-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yxx4c%2Fcache-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261348748,"owners_count":23145312,"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-12-14T03:29:39.463Z","updated_at":"2025-06-22T19:07:53.778Z","avatar_url":"https://github.com/yxx4c.png","language":"TypeScript","readme":"# cache-utils\n\n`cache-utils` is a versatile library designed to complement the [prisma-redis-cache](https://github.com/yxx4c/prisma-redis-cache) and [prisma-redis-uncache](https://github.com/yxx4c/prisma-redis-uncache) libraries. It offers general-purpose functions for efficient Redis/DragonflyDB database maintenance.\n\n🚀 If `cache-utils` proves helpful, consider giving it a star! [⭐ Star Me!](https://github.com/yxx4c/cache-utils)\n\n## Installation\n\n#### Using npm:\n\n```bash\nnpm install @yxx4c/cache-utils\n```\n\n#### Using yarn:\n\n```bash\nyarn add @yxx4c/cache-utils\n```\n\n#### Using pnpm:\n\n```bash\npnpm add @yxx4c/cache-utils\n```\n\n#### Using bun:\n\n```bash\nbun add @yxx4c/cache-utils\n```\n\n## Example\n\n```javascript\nimport { getCacheKey, getCacheKeyPattern } from '@yxx4c/cache-utils';\n\n// ...Extend Prisma with prisma-redis-cache\n\n// Query a user and cache the result with custom configuration\nprismaWithCache.user.findUnique({\n  where: { id },\n  cache: { ttl: 5, key: getCacheKey([{ prisma: 'User' }, { userId: id }]) },\n});\n\n// ...Extend Prisma with prisma-redis-uncache\n\n// Example: Update a user and invalidate related cache keys\nprismaWithUncache.user.update({\n  where: { id },\n  data: { username },\n  uncache: {\n    uncacheKeys: [\n      getCacheKey([{ prisma: 'User' }, { userId: id }]),\n      getCacheKeyPattern([{ prisma: '*' }, { userId: id }]), // Pattern matching under a specific key, eg: prisma:*:userId:1234\n      getCacheKeyPattern([{ prisma: 'Post' }, { userId: id }, { glob: '*' }]), // Utilizing the key 'glob' to create a wildcard region, eg: prisma:post:userId:1234:*\n    ],\n    hasPattern: true,\n  },\n});\n```\n\nIntegrate `cache-utils` seamlessly with `prisma-redis-cache` and `prisma-redis-uncache` for comprehensive Redis/DragonflyDB database management. If you find value in this library, show your support by giving it a star on [GitHub](https://github.com/yxx4c/cache-utils).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyxx4c%2Fcache-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyxx4c%2Fcache-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyxx4c%2Fcache-utils/lists"}