Skip to content

Commit ba58646

Browse files
docs(cache): change seconds to miliseconds (ttl)
1 parent 0692e44 commit ba58646

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

content/techniques/caching.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ await this.cacheManager.set('key', 'value');
5454

5555
> warning **Note** The in-memory cache storage can only store values of types that are supported by [the structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#javascript_types).
5656
57-
The default expiration time of the cache is 5 seconds.
58-
59-
You can manually specify a TTL (expiration time in seconds) for this specific key, as follows:
57+
You can manually specify a TTL (expiration time in miliseconds) for this specific key, as follows:
6058

6159
```typescript
6260
await this.cacheManager.set('key', 'value', 1000);
6361
```
6462

63+
Where `1000` is the TTL in milliseconds - in this case, the cache item will expire after one second.
64+
6565
To disable expiration of the cache, set the `ttl` configuration property to `0`:
6666

6767
```typescript
@@ -121,14 +121,13 @@ import { APP_INTERCEPTOR } from '@nestjs/core';
121121
export class AppModule {}
122122
```
123123

124-
#### Customize caching
124+
#### Time-to-live (TTL)
125125

126-
All cached data has its own expiration time ([TTL](https://en.wikipedia.org/wiki/Time_to_live)). To customize default values, pass the options object to the `register()` method.
126+
The default value for `ttl` is `0`, meaning the cache will never expire. To specify a custom [TTL](https://en.wikipedia.org/wiki/Time_to_live), you can provide the `ttl` option in the `register()` method, as demonstrated below:
127127

128128
```typescript
129129
CacheModule.register({
130-
ttl: 5, // seconds
131-
max: 10, // maximum number of items in cache
130+
ttl: 5000, // milliseconds
132131
});
133132
```
134133

0 commit comments

Comments
 (0)