Skip to content

Commit 1d6eac1

Browse files
Oxyjunsdnts
authored andcommitted
Clarifying CacheTtl max value and cached reads. (cloudflare#23501)
1 parent 929f780 commit 1d6eac1

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/content/docs/kv/api/read-key-value-pairs.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,11 @@ A hot read means that the data is cached on Cloudflare's edge network using the
249249
250250
`cacheTtl` is not recommended if your data is updated often and you need to see updates shortly after they are written, because writes that happen from other global network locations will not be visible until the cached value expires.
251251
252-
The `cacheTtl` parameter must be an integer greater than or equal to `60`, which is the default.
252+
The `cacheTtl` parameter must be an integer greater than or equal to `60`, which is the default. The maximum value for `cacheTtl` is [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).
253253
254-
The effective `cacheTtl` of an already cached item can be reduced by getting it again with a lower `cacheTtl`. For example, if you did `NAMESPACE.get(key, {cacheTtl: 86400})` but later realized that caching for 24 hours was too long, you could `NAMESPACE.get(key, {cacheTtl: 300})` or even `NAMESPACE.get(key)` and it would check for newer data to respect the provided `cacheTtl`, which defaults to 60 seconds. This overwriting `cacheTtl` behavior will only take effect in regions where the key-value pair is read with the updated `cacheTtl`. In other words, reading a key-value pair in a given region will update the cache time-to-live in that region but not in other regions of Cloudflare's network (these will keep the time-to-live from the last read of the region).
254+
The effective `cacheTtl` of an already cached item can be reduced by getting it again with a lower `cacheTtl`. For example, if you did `NAMESPACE.get(key, {cacheTtl: 86400})` but later realized that caching for 24 hours was too long, you could `NAMESPACE.get(key, {cacheTtl: 300})` or even `NAMESPACE.get(key)` and it would check for newer data to respect the provided `cacheTtl`, which defaults to 60 seconds. This overwriting `cacheTtl` behavior will only take effect in regions where the key-value pair is read with the updated `cacheTtl`. In other words, reading a key-value pair in a given region will update the cache time-to-live in that region but not in other regions of Cloudflare's network (these will keep the time-to-live from the last read of the region).
255+
256+
Reading KV values while it is cached still incurs cost in line with Workers KV [limits](/kv/platform/limits/) and [pricing](/kv/platform/pricing/).
255257
256258
### Requesting more keys per Worker invocation with bulk requests
257259

src/content/docs/kv/platform/limits.mdx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ sidebar:
66

77
---
88

9-
10-
119
import { Render } from "~/components"
1210

13-
| Feature | Free | Paid |
14-
| --------------------------------- | --------------------- | ------------ |
15-
| Reads | 100,000 reads per day | Unlimited |
16-
| Writes to different keys | 1,000 writes per day | Unlimited |
17-
| Writes to same key | 1 per second | 1 per second |
18-
| Operations/Worker invocation [^1] | 1000 | 1000 |
19-
| Namespaces | 1000 | 1000 |
20-
| Storage/account | 1 GB | Unlimited |
21-
| Storage/namespace | 1 GB | Unlimited |
22-
| Keys/namespace | Unlimited | Unlimited |
23-
| Key size | 512 bytes | 512 bytes |
24-
| Key metadata | 1024 bytes | 1024 bytes |
25-
| Value size | 25 MiB | 25 MiB |
26-
| Minimum [`cacheTtl`](/kv/api/read-key-value-pairs/#cachettl-parameter) | 60 seconds | 60 seconds |
11+
| Feature | Free | Paid |
12+
| ------------------------------------------------------------------------------ | --------------------- | ------------ |
13+
| Reads | 100,000 reads per day | Unlimited |
14+
| Writes to different keys | 1,000 writes per day | Unlimited |
15+
| Writes to same key | 1 per second | 1 per second |
16+
| Operations/Worker invocation [^1] | 1000 | 1000 |
17+
| Namespaces | 1000 | 1000 |
18+
| Storage/account | 1 GB | Unlimited |
19+
| Storage/namespace | 1 GB | Unlimited |
20+
| Keys/namespace | Unlimited | Unlimited |
21+
| Key size | 512 bytes | 512 bytes |
22+
| Key metadata | 1024 bytes | 1024 bytes |
23+
| Value size | 25 MiB | 25 MiB |
24+
| Minimum [`cacheTtl`](/kv/api/read-key-value-pairs/#cachettl-parameter) [^2] | 60 seconds | 60 seconds |
2725

2826
[^1]: Within a single invocation, a Worker can make up to 1,000 operations to external services (for example, 500 Workers KV reads and 500 R2 reads). A bulk request to Workers KV counts for 1 request to an external service.
2927

28+
[^2]: The maximum value is [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).
29+
3030
<Render file="limits_increase" product="workers" />
3131

3232
:::note[Free versus Paid plan pricing]

0 commit comments

Comments
 (0)