Skip to content

Commit 2827db2

Browse files
committed
nic-112 describe fs-layer in readmes
1 parent bdfb988 commit 2827db2

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ Create your custom cache handler:
2828

2929
```ts
3030
// cache-handlers/default.js
31-
import { CacheHandler, LruLayer, RedisLayer } from "@nimpl/cache";
31+
import { CacheHandler, LruLayer, FsLayer } from "@nimpl/cache";
3232

3333
export default new CacheHandler({
3434
ephemeralLayer: new LruLayer(),
35-
persistentLayer: new RedisLayer(),
35+
persistentLayer: new FsLayer(),
3636
});
3737
```
3838

packages/cache-redis/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Redis-based cache handler with multi-pod support. Designed for Next.js but can b
66

77
`@nimpl/cache-redis` is a showcase library that demonstrates how to build a cache handler using `@nimpl/cache`. It implements a two-tier caching strategy: an in-memory LRU cache for fast local access and Redis for shared cache across multiple pods.
88

9-
> **Note**: This is a showcase library. In most cases, users should build their own cache-handler using `@nimpl/cache` to have full control over configuration and layers.
9+
> **Note**: This is a showcase library. In most cases, you should build your own cache-handler using `@nimpl/cache` to have full control over configuration and layers.
1010
>
1111
> **For detailed information on handlers, layers, custom implementations, and advanced configuration, see the [`@nimpl/cache` README](../cache/README.md).**
1212

packages/cache/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,24 @@ Options (`RedisLayerOptions`):
7373
- `"wait-throw"`: The handler will attempt to connect to Redis and throw an error if the connection fails. Next.js will stop working with the handler for the entire process in this case.
7474
- `"wait-exit"`: The handler will attempt to connect to Redis and exit the process with code 1 if the connection is unsuccessful.
7575

76-
> **Note**: Next.js has internal caching layers. For static segments this means that even with `wait-throw` or `wait-exit` strategies, users may still receive data from Next.js internal layers before process exit. It's recommended to use these modes with readiness checks to properly handle this scenario.
76+
> **Note**: Next.js has internal caching layers. For static segments this means that even with `wait-throw` or `wait-exit` strategies, you may still receive data from Next.js internal layers before process exit. It's recommended to use these modes with readiness checks to properly handle this scenario.
7777
7878
Cache entries are stored with separate keys for data and metadata for better performance. Metadata includes cache lifetimes and tag list.
7979

8080
All cache entries have auto-delete configuration and are removed automatically when they expire. This optimizes memory usage by ensuring stale data is cleaned up and helps prioritize frequently accessed data.
8181

82+
**Filesystem Client** - Persistent cache using the local filesystem. Stores cache entries as files on disk, making it suitable for single-instance deployments, development environments, or multi-pod deployments with shared mounted directories.
83+
84+
Options (`FsLayerOptions`):
85+
86+
- `baseDir` (string): Base directory for storing cache files. Default: `process.env.NIC_FS_BASE_DIR || ".cache/nimpl-cache"`
87+
88+
The filesystem layer stores cache entries with separate files for data and metadata, similar to the Redis layer. Metadata includes cache lifetimes and tag list. Cache files are stored using URL-encoded keys to ensure filesystem compatibility.
89+
90+
Expired entries are detected and not returned, but files are not automatically deleted from disk. You may need to implement periodic cleanup if disk space is a concern.
91+
92+
> **Note**: In multi-pod deployments without shared volumes, each pod will have its own filesystem cache, which won't be shared between instances.
93+
8294
## Configuration
8395

8496
### Options

0 commit comments

Comments
 (0)