Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,3 @@ You've successfully set up Prisma ORM. Here's what you can explore next:
- [Prisma Config reference](/orm/reference/prisma-config-reference)
- [Database introspection](/orm/prisma-schema/introspection)
- [Prisma Migrate](/orm/prisma-migrate)
- [Cache your queries](/postgres/database/caching#setting-up-caching-in-prisma-postgres)
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,3 @@ You've successfully set up Prisma ORM. Here's what you can explore next:
- [Prisma Postgres documentation](/postgres)
- [Prisma Config reference](/orm/reference/prisma-config-reference)
- [Database connection management](/orm/prisma-client/setup-and-configuration/databases-connections)
- [Cache your queries](/postgres/database/caching#setting-up-caching-in-prisma-postgres)
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ This time, you're seeing two `User` objects being printed. Both of them have a `

## Next steps

You just got your feet wet with a basic Prisma Postgres setup. If you want to explore more complex queries, such as [adding caching functionality](/postgres/database/caching#setting-up-caching-in-prisma-postgres), check out the official [Quickstart](/prisma-orm/quickstart/prisma-postgres).
You just got your feet wet with a basic Prisma Postgres setup. Check out the official [Quickstart](/prisma-orm/quickstart/prisma-postgres).

### View and edit data in Prisma Studio

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,3 @@ You've successfully set up Prisma ORM. Here's what you can explore next:
- [Prisma Postgres documentation](/postgres)
- [Prisma Config reference](/orm/reference/prisma-config-reference)
- [Database connection management](/orm/prisma-client/setup-and-configuration/databases-connections)
- [Cache your queries](/postgres/database/caching#setting-up-caching-in-prisma-postgres)
2 changes: 0 additions & 2 deletions apps/docs/content/docs/accelerate/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ metaDescription: Learn everything you need to know to use Accelerate's global da
---

Prisma Accelerate provides global caching for read queries using TTL, Stale-While-Revalidate (SWR), or a combination of both. It's included as part of Prisma Postgres, but can also be used with your own database by enabling Accelerate in the [Prisma Data Platform](https://console.prisma.io?utm_source=docs) and [configuring it with your database](/accelerate/getting-started).

This content has moved — learn more on the updated [Caching in Accelerate](/postgres/database/caching) page.
4 changes: 2 additions & 2 deletions apps/docs/content/docs/accelerate/compare.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Prisma Accelerate offers a powerful global cache, so you can serve data to your

**Why are these important?**

- Since Accelerate extends the Prisma client, you can control caching policies directly from your codebase with just an extra line of code. Integration is seamless. Here is an example using [the stale-while-revalidating caching strategy](/postgres/database/caching#stale-while-revalidate-swr):
- Since Accelerate extends the Prisma client, you can control caching policies directly from your codebase with just an extra line of code. Integration is seamless. Here is an example using the stale-while-revalidating caching strategy:
```jsx
await prisma.user.findMany({
cacheStrategy: {
Expand All @@ -49,7 +49,7 @@ Prisma Accelerate offers a powerful global cache, so you can serve data to your
```
- Query level cache policies are critical for serious applications, so that you can control which queries are cached, and the characteristics of the policy. You may want certain data in your app to be cached for several days, other data to be cached for a just a few minutes, and other data to be not cached at all. This is only possible with Prisma Accelerate.
- Authenticating with an API key can be a helpful security measure, allowing you to decouple database credentials from application secrets. Easily rotate API keys as often as you like, without needing any credential changes in your database
- Automatic cache updates means that the cache is automatically updated when a change in the database occurs. With Accelerate, you are in control of how the cache is invalidated, using [various caching strategies](/postgres/database/caching).
- Automatic cache updates means that the cache is automatically updated when a change in the database occurs. With Accelerate, you are in control of how the cache is invalidated, using [various caching strategies](/accelerate/caching).

## Accelerate connection pool

Expand Down
22 changes: 1 addition & 21 deletions apps/docs/content/docs/accelerate/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,6 @@ If you simply want to take advantage of Accelerate's connection pooling feature

By enabling Accelerate and supplying the Accelerate connection string, your queries now use the connection pooler by default.

#### Define a cache strategy

Update a query with the new `cacheStrategy` property which allows you to define a cache strategy for that specific query:

```ts
const user = await prisma.user.findMany({
where: {
email: {
contains: "alice@prisma.io",
},
},
cacheStrategy: { swr: 60, ttl: 60 },
});
```

In the example above, `swr: 60` and `ttl: 60` means Accelerate will serve cached data for 60 seconds and then another 60 seconds while Accelerate fetches fresh data in the background.

You should now see improved performance for your cached queries.

For information about which strategy best serves your application, see [Select a cache strategy](/postgres/database/caching#selecting-a-cache-strategy).

:::info

Expand All @@ -203,7 +183,7 @@ As of Prisma version `5.2.0` you can use Prisma Studio with the Accelerate conne

#### Invalidate the cache and keep your cached query results up-to-date

If your application requires real-time or near-real-time data, cache invalidation ensures that users see the most current data, even when using a large `ttl` (Time-To-Live) or `swr` (Stale-While-Revalidate) [cache strategy](/postgres/database/caching#cache-strategies). By invalidating your cache, you can bypass extended caching periods to show live data whenever it's needed.
If your application requires real-time or near-real-time data, cache invalidation ensures that users see the most current data, even when using a large `ttl` (Time-To-Live) or `swr` (Stale-While-Revalidate) [cache strategy](/accelerate/caching). By invalidating your cache, you can bypass extended caching periods to show live data whenever it's needed.

For example, if a dashboard displays customer information and a customer’s contact details change, cache invalidation allows you to refresh only that data instantly, ensuring support staff always see the latest information without waiting for the cache to expire.

Expand Down
8 changes: 3 additions & 5 deletions apps/docs/content/docs/accelerate/more/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ Accelerate does not have a consistency model. It is not a distributed system whe

Accelerate implements a [read-through caching strategy](https://www.prisma.io/dataguide/managing-databases/introduction-database-caching#read-through) particularly suitable for read-heavy workloads.

The freshness of the data served by the cache depends on the cache strategy defined in your query. Refer to [this section](/postgres/database/caching#selecting-a-cache-strategy) for more information on selecting the right cache strategy for your query.

## How is Accelerate different from other caching tools, such as Redis?

- Accelerate is a _specialized_ cache that allows you to optimize data access in code at the query level with a cache strategy. On the other hand, tools such as Redis and Memcached are _general-purpose_ caches designed to be adaptable and flexible.
Expand All @@ -116,7 +114,7 @@ No. We currently do not have any plans for supporting other ORMs/query builders

## What is the maximum allowed value for the `ttl` parameter when configuring `cacheStrategy`?

The [Time-to-live](/postgres/database/caching#time-to-live-ttl) (`ttl`) parameter can be set for up to a _year_. However, it's important to note that items within the cache may be evicted if they are not frequently accessed.
The [Time-to-live](/accelerate/caching) (`ttl`) parameter can be set for up to a _year_. However, it's important to note that items within the cache may be evicted if they are not frequently accessed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify eviction wording for consistency.

This sentence implies eviction is mainly tied to low access frequency, but Line 121 states even frequently accessed items can still be evicted. Tightening this wording will avoid mixed expectations.

Suggested text update
-The [Time-to-live](/accelerate/caching) (`ttl`) parameter can be set for up to a _year_. However, it's important to note that items within the cache may be evicted if they are not frequently accessed.
+The [Time-to-live](/accelerate/caching) (`ttl`) parameter can be set for up to a _year_. However, cache entries may still be evicted before `ttl` is reached, including in some cases for frequently accessed items.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The [Time-to-live](/accelerate/caching) (`ttl`) parameter can be set for up to a _year_. However, it's important to note that items within the cache may be evicted if they are not frequently accessed.
The [Time-to-live](/accelerate/caching) (`ttl`) parameter can be set for up to a _year_. However, cache entries may still be evicted before `ttl` is reached, including in some cases for frequently accessed items.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/docs/content/docs/accelerate/more/faq.mdx` at line 117, Update the
sentence about cache eviction to avoid implying eviction only happens for
infrequently accessed items: keep the TTL upper bound (one year) but add that
cached items may be evicted due to cache policies or capacity constraints
regardless of access frequency (so even frequently accessed items can be
removed); modify the "Time-to-live" / `ttl` sentence to explicitly state both
the max TTL and that eviction can occur for any item due to eviction policies or
resource limits to match the later statement.


Based on our experimentation, we’ve seen cache items persist for around 18 hours. While items may remain in the cache for an extended period if they are actively accessed, there is no guarantee.

Expand Down Expand Up @@ -182,11 +180,11 @@ Here is a [demo app](https://pris.ly/test-cache-invalidation) to test the time i

## What is on-demand cache invalidation?

[On-demand cache invalidation](/postgres/database/caching#on-demand-cache-invalidation) lets applications instantly update specific cached data when it changes, instead of waiting for regular cache refresh cycles. This keeps information accurate and up-to-date for users.
[On-demand cache invalidation](/accelerate/caching) lets applications instantly update specific cached data when it changes, instead of waiting for regular cache refresh cycles. This keeps information accurate and up-to-date for users.

## When should I use the cache invalidate API?

The [cache invalidate API](/postgres/database/caching#on-demand-cache-invalidation) is essential when data consistency cannot wait for the cache’s standard expiration or revalidation. Key use cases include:
The [cache invalidate API](/accelerate/caching) is essential when data consistency cannot wait for the cache’s standard expiration or revalidation. Key use cases include:

- **Content updates**: When critical changes occur, such as edits to a published article, product updates, or profile modifications, that need to be visible immediately.
- **Inventory management**: In real-time applications, like inventory or booking systems, where stock levels, availability, or reservation statuses must reflect the latest information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ All example are based on the `User` model.

## `cacheStrategy`

With the Accelerate extension for Prisma Client, you can use the `cacheStrategy` parameter for model queries and use the [`ttl`](/postgres/database/caching#time-to-live-ttl) and [`swr`](/postgres/database/caching#stale-while-revalidate-swr) parameters to define a cache strategy for Accelerate. The Accelerate extension requires that you install Prisma Client version `4.10.0`.
With the Accelerate extension for Prisma Client, you can use the `cacheStrategy` parameter for model queries and use the [`ttl`](/accelerate/caching) and [`swr`](/accelerate/caching) parameters to define a cache strategy for Accelerate. The Accelerate extension requires that you install Prisma Client version `4.10.0`.

### Options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ Now that you have a working Astro app with Clerk authentication and Prisma conne
- Build protected API routes that require authentication
- Extend your schema with additional models related to users
- Deploy to your preferred hosting platform and set your production webhook URL in Clerk
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance

### More info

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,6 @@ Below are some next steps to explore, as well as some more resources to help you
- Add delete functionality to posts and users.
- Add a search bar to filter posts.
- Deploy to Vercel and set your production webhook URL in Clerk.
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance

### More Info

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ Now that you have a working Cloudflare Workers app connected to a Prisma Postgre
- Extend your Prisma schema with more models and relationships
- Implement authentication and authorization
- Use [Hono](https://hono.dev/) for a more robust routing framework with Cloudflare Workers (see our [Hono guide](/guides/frameworks/hono))
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance

### More info

Expand Down
1 change: 0 additions & 1 deletion apps/docs/content/docs/guides/frameworks/astro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ Now that you have a working Astro app connected to a Prisma Postgres database, y
- Extend your Prisma schema with more models and relationships
- Add create/update/delete routes and forms
- Explore authentication and validation
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance

### More Info

Expand Down
1 change: 0 additions & 1 deletion apps/docs/content/docs/guides/frameworks/elysia.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ Now that you have a working Elysia app connected to a Prisma Postgres database,
- Extend your Prisma schema with more models and relationships
- Add update and delete endpoints
- Explore authentication with [Elysia plugins](https://elysiajs.com/plugins/overview.html)
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance
- Use [Eden](https://elysiajs.com/eden/overview.html) for end-to-end type-safe API calls

### More info
Expand Down
1 change: 0 additions & 1 deletion apps/docs/content/docs/guides/frameworks/hono.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ Now that you have a working Hono app connected to a Prisma Postgres database, yo
- Extend your Prisma schema with more models and relationships
- Add create/update/delete routes and forms
- Explore authentication and validation
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance

### More Info

Expand Down
1 change: 0 additions & 1 deletion apps/docs/content/docs/guides/frameworks/solid-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ Now that you have a working SolidStart app connected to a Prisma Postgres databa
- Extend your Prisma schema with more models and relationships
- Add create/update/delete routes and forms
- Explore authentication, validation, and optimistic updates
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance

## More Info

Expand Down
1 change: 0 additions & 1 deletion apps/docs/content/docs/guides/frameworks/sveltekit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ Now that you have a working SvelteKit app connected to a Prisma Postgres databas
- Extend your Prisma schema with more models and relationships
- Add create/update/delete routes and forms
- Explore authentication and validation
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance

### More Info

Expand Down
1 change: 0 additions & 1 deletion apps/docs/content/docs/guides/integrations/ai-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ Now that you have a working AI SDK chat application connected to a Prisma Postgr
- Extend your Prisma schema with more models and relationships
- Add create/update/delete routes and forms
- Explore authentication and validation
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance

### More Info

Expand Down
1 change: 0 additions & 1 deletion apps/docs/content/docs/guides/integrations/shopify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ Now that you have a working Shopify app connected to a Prisma Postgres database,
- Extend your Prisma schema with more models and relationships
- Add create/update/delete routes and forms
- Enable query caching with [Prisma Postgres](/postgres/database/caching) for better performance
### More Info
Expand Down
Loading
Loading