{"id":21078566,"url":"https://github.com/prisma/prisma-accelerate-invalidation","last_synced_at":"2025-04-12T22:37:29.296Z","repository":{"id":260640639,"uuid":"881926635","full_name":"prisma/prisma-accelerate-invalidation","owner":"prisma","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-22T16:20:21.000Z","size":48526,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T16:11:20.074Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://test-cache-invalidation.prisma.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prisma.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-01T14:08:22.000Z","updated_at":"2025-04-04T04:35:59.000Z","dependencies_parsed_at":"2024-11-01T15:30:00.046Z","dependency_job_id":null,"html_url":"https://github.com/prisma/prisma-accelerate-invalidation","commit_stats":null,"previous_names":["nurul3101/prisma-accelerate-invalidation","prisma/prisma-accelerate-invalidation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma-accelerate-invalidation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma-accelerate-invalidation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma-accelerate-invalidation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma-accelerate-invalidation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prisma","download_url":"https://codeload.github.com/prisma/prisma-accelerate-invalidation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643008,"owners_count":21138353,"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-11-19T19:40:58.339Z","updated_at":"2025-04-12T22:37:29.261Z","avatar_url":"https://github.com/prisma.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prisma Accelerate Cache Invalidation Test\n\nThis project demonstrates [cache invalidation](https://www.prisma.io/docs/accelerate/caching#on-demand-cache-invalidation) timing in a Next.js application using Prisma and [Prisma Accelerate](https://www.prisma.io/accelerate), with a Time-to-Live (TTL) strategy. It measures the time it takes for cache invalidation to reflect updated data.\n\n## Application overview\n\nThe app provides an interactive interface to test cache invalidation behavior.\n\n![Accelerate Cache Invalidation GIF](./accelerate-cache-invalidation.gif)\n\n### How it works:\n\n1. A quote is fetched with a TTL of 60 seconds.\n2. The fetched quote is cached.\n3. The quote is updated in the database.\n4. The cache is invalidated using Prisma Accelerate's `$invalidate` API.\n5. The app polls the API until the updated quote is fetched.\n6. The total time for invalidation to take effect is displayed, including frontend-to-backend roundtrip delays.\n\n## Prerequisites\n\nBefore you begin, ensure you have the following prerequisites:\n\n- Obtain an Accelerate API key from [Prisma Data Platform](https://pris.ly/pdp).\n- Create a `.env` file in the project root directory with the following content:\n\n```bash\n# Accelerate connection string\nDATABASE_URL=\"prisma://accelerate.prisma-data.net/?api_key=ACCELERATE_API_KEY\"\n\n# To run migrations\nDIRECT_URL=\"postgresql://username:password@host:5432/database_name\"\n```\n\n## Getting Started\n\nTo get started with this project, follow these steps:\n\n1. Install project dependencies:\n\n```bash\nnpm install\n```\n\n2. Set up Prisma by running migrations and generating a PrismaClient for edge functions:\n\n```bash\nnpx prisma migrate dev\nnpx prisma db seed\nnpx prisma generate --no-engine\n```\n\n3. Start the application:\n\n```bash\nnpm run dev\n```\n\nThe app will run at http://localhost:3000.\n\n## How to use the app\n\n1. Click the “Start cache invalidation test” button on the homepage.\n2. Observe the timeline for cache invalidation and updated data retrieval.\n3. Review the displayed total invalidation time.\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests to improve this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fprisma-accelerate-invalidation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprisma%2Fprisma-accelerate-invalidation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fprisma-accelerate-invalidation/lists"}