Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README and documentation and the default expire age calculation #879

Merged
merged 2 commits into from
Nov 26, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/flat-boxes-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@neshca/cache-handler': minor
---

Updated the documentation and peer dependencies to explicitly state that only Next.js versions `13.5.x` and `14.x.x` are supported. Modified the default `estimateExpireAge` function to perform the calculation as `(staleAge) => staleAge * 1.5`.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Explore the versatility of `@neshca/cache-handler` in our [Examples Section](htt

## Requirements

- **Next.js**: 13.5.1 or newer.
- **Next.js**: 13.5.1 or newer (below 15.0.0).
- **Node.js**: 18.17.0 or newer.

## Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Stale age is the time after which the cache entry is considered stale, can be se

### `estimateExpireAge`

Estimates the expiration age based on the stale age.
Estimates the expiration age based on the stale age. Defaults to `(staleAge) => staleAge * 1.5`.

Expire age is the time after which the cache entry is considered expired and should be removed from the cache and must not be served.

Expand Down
6 changes: 3 additions & 3 deletions docs/cache-handler-docs/src/pages/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ This section guides you through the initial setup and basic usage of `@neshca/ca

### Prerequisites

- **Node.js:** Version 18.17 or newer.
- **Next.js:** Version 13.5.1 or newer.
- **Redis (optional):** Version 4.6.0 or newer.
- **Node.js:** 18.17 or newer.
- **Next.js:** 13.5.1 or newer (below 15.0.0).
- **Redis (optional):** 4.6.0 or newer.

### Quick Start Installation

Expand Down
14 changes: 3 additions & 11 deletions docs/cache-handler-docs/theme.config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,11 @@ export default {
),
},
banner: {
key: 'version-1.8.0',
key: 'version-1.9.0',
content: (
<div>
🎉 Version 1.8.0 is out! Use shared cache for the Next.js Pages API routes and getServerSideProps with{' '}
<a
href="/functions/nesh-classic-cache"
style={{
color: 'lightgreen',
fontFamily: 'monospace',
}}
>
neshClassicCache
</a>
🎉 Version 1.9.0 is out! This is the final release supporting Next.js 13.5.1-14.x. The upcoming version
2.0.0 will require Next.js 15.
</div>
),
},
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/cache-handler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

## Latest Release

🎉 **Version 1.8.0** has been released! It now includes the [`neshClassicCache` function ↗](https://caching-tools.github.io/next-shared-cache/functions/nesh-classic-cache), that allows you to cache the results of expensive operations in the `getServerSideProps` and API routes.
🎉 **Version 1.9.0** has been released! It changes the default `estimateExpireAge` function to perform the calculation as `(staleAge) => staleAge * 1.5` to better align with the default Next.js cache behavior.

Do not forget the [`registerInitialCache` instrumentation hook ↗](https://caching-tools.github.io/next-shared-cache/usage/populating-cache-on-start), that allows the cache to be pre-populated with the initial data when the application starts.
This is the final release leading up to version 2.0.0. The upcoming version 2 will bring significant changes and will no longer support Next.js versions 13 and 14. While version 1 will still receive ongoing maintenance, it won't get any new features.

Check out the [changelog](https://github.com/caching-tools/next-shared-cache/blob/canary/packages/cache-handler/CHANGELOG.md) for more details.

Expand Down Expand Up @@ -50,7 +50,7 @@ Explore the versatility of `@neshca/cache-handler` in our [Examples Section](htt

## Requirements

- **Next.js**: 13.5.1 or newer.
- **Next.js**: 13.5.1 or newer (below 15.0.0).
- **Node.js**: 18.17.0 or newer.

## Documentation
Expand Down
2 changes: 1 addition & 1 deletion packages/cache-handler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"typescript": "5.7.2"
},
"peerDependencies": {
"next": ">= 13.5.1",
"next": ">= 13.5.1 < 15",
"redis": ">= 4.6"
},
"distTags": [
Expand Down
2 changes: 1 addition & 1 deletion packages/cache-handler/src/cache-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export type TTLParameters = {
* After the stale age, the cache entry is considered stale, can be served from the cache, and should be revalidated.
* Revalidation is handled by the `CacheHandler` class.
*
* @default (staleAge) => staleAge
* @default (staleAge) => staleAge * 1.5
*
* @returns The expiration age in seconds.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type EstimateExpireAgeFunction = typeof getInitialExpireAge;
* @returns The initial expire age.
*/
export function getInitialExpireAge(staleAge: number): number {
return staleAge;
return staleAge * 1.5;
}

/**
Expand Down