Vercel News
Vercel Blob now supports consistent reads on private storage
8.5内容质量
TL;DR · AI 摘要
Vercel Blob 现在支持私有存储的一致性读取,通过 useCache: false 参数可绕过缓存获取最新写入数据。
核心要点
- 使用 useCache: false 可绕过缓存,确保读取最新数据
- 覆盖文件后缓存可能延迟60秒更新,需显式禁用缓存
- 需安装 @vercel/blob@2.6.1 SDK 启用该功能
结构提纲
按章节快速跳转。
- §功能发布
宣布 Vercel Blob 新增私有存储一致性读取功能
- ·核心机制
通过 useCache: false 参数实现读写一致性
- ›缓存行为
覆盖文件后缓存延迟60秒更新
- ·实现方式
支持 SDK 调用或直接设置 cache=0 参数
- ›性能影响
一致性读取会触发 Fast Origin Transfer
- ·版本要求
需安装 @vercel/blob@2.6.1 SDK
思维导图
用一张图看清主题之间的关系。
查看大纲文本(无障碍 / 无 JS 友好)
- Vercel Blob 一致性读取
- 核心机制
- useCache: false 参数
- 缓存行为
- 60秒延迟更新
- Fast Origin Transfer
- 实现方式
- SDK 调用
- URL 参数设置
金句 / Highlights
值得收藏与分享的关键句。
Pass useCache: false to get() or presignUrl() for a read that reflects the latest write.
When you overwrite a blob at an existing pathname, readers might see the cached version for up to 60 seconds.
useCache: false adds a cache=0 query parameter to the request.
#Vercel#Blob#存储#一致性读取
打开原文Vercel Blob 现在支持私有存储的强一致性读取 - Vercel
Vercel Blob 现在支持对私有存储的强一致性读取。通过在 get() 或 presignUrl() 中传递 useCache: false,可以获取反映最新写入的读取结果。
写入新路径名的 blob 没有现有的缓存条目,因此读取会立即反映最新的写入。当您覆盖现有路径名下的 blob 时,读取者可能会在 60 秒内看到缓存版本。
当读取必须反映最新写入时(例如代理的内存文件、会话记录或计划的 JSON 报告),请传递 useCache: false。这些读取会绕过 CDN,耗时比缓存读取更长,并会产生 Fast Origin Transfer 费用。
code
1
import
{
put
,
get
}
from
'@vercel/blob'
;
2
3
await
put
(
'reports/latest.json'
,
JSON
.
stringify
(
report
)
,
{
4
access
:
'private'
,
5
}
)
;
6
7
// 新创建的 blob 具有写后读一致性:此读取会反映最新的写入
8
let
result
=
await
get
(
'reports/latest.json'
,
{
access
:
'private'
}
)
;
9
10
11
// 在相同路径名下覆盖报告
12
await
put
(
'reports/latest.json'
,
JSON
.
stringify
(
updatedReport
)
,
{
13
access
:
'private'
,
14
allowOverwrite
:
true
,
15
}
)
;
16
17
// 默认读取可能在 60 秒内返回旧版本
// 强一致性读取保证反映更新:
18
result
=
await
get
(
'reports/latest.json'
,
{
19
access
:
'private'
,
20
useCache
:
false
,
21
}
)
;您也可以不通过 SDK 绕过缓存。在底层实现中,useCache: false 会向请求添加 cache=0 查询参数。您可以在私有 blob URL 上自行设置:
code
1
curl
"https://<store-id>.private.blob.vercel-storage.com/file.json?cache=0"
\
2
-H
"Authorization: Bearer
$BLOB_READ_WRITE_TOKEN
"安装最新版 @vercel/blob SDK 以使用强一致性读取:
code
1
npm
install
@vercel/blob@2.6.1了解更多关于强一致性读取的信息,请参阅相关文档 。