-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the incremental cache storage and cache providers extensible.
This will especially allow developers to store pages in object storages like S3 and shared cache like Redis. Thanks to that, all Next instances can share the same cache pool, therefore it increase the overall performances depending on the company infrastructure. This commit basically changes nothing to the Next.js current features and behaviors. It just allow us to to use plugins to customize that behavior.
- Loading branch information
1 parent
6c59b77
commit d4f53eb
Showing
3 changed files
with
65 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { promises } from 'fs' | ||
|
||
export interface StorageProfiderInterface { | ||
readValue: (key: string) => Promise<string> | ||
write: (key: string, value: string | undefined) => Promise<void> | ||
} | ||
|
||
export class FileSystemStorageProvider implements StorageProfiderInterface { | ||
async readValue(key: string): Promise<string> { | ||
return await promises.readFile(key, 'utf8') | ||
} | ||
|
||
async write(key: string, value: string | undefined) { | ||
await promises.mkdir(key.substring(0, key.lastIndexOf('/')), { | ||
recursive: true, | ||
}) | ||
await promises.writeFile(key, String(value), 'utf8') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters