キャッシュ内のデータ更新
update() メソッドを使用して、キャッシュセグメント内のキーと値のペアを更新できます。String 型のキー名とキー値を引数として渡す必要があります。値が存在しない場合は、キャッシュセグメントに挿入されます。ここで返される Promise は JSON オブジェクトに解決されます。
オプションで有効期限パラメータを渡すこともできます。値を指定しない場合、有効期限はデフォルトで 48 時間に設定されます。
以下のコードスニペットで使用している segment の参照は、以前作成したセグメントインスタンスです。
copy
//Update cache by passing the key-value pair
let cache = app.cache();
let segment = cache.segment();
let cachePromise = segment.update('Name', 'Micheal Greene');
cachePromise.then((entity) => { console.log(entity); });
各バージョンで受信するサンプルレスポンスを以下に示します:
Node JS
copy
{
cache_name: "Last_Name",
cache_value: "Brown",
project_details: { project_name: "AlienCity", id: "2136000000007733" },
segment_details: { segment_name: "DataStore", id: "2136000000008572" },
expires_in: "Aug 18, 2021 06:46 PM",
expiry_in_hours: "47",
ttl_in_milliseconds: "172596000"
}
{
cache_name: "Last_Name",
cache_value: "Brown",
project_details: { project_name: "AlienCity", id: 2136000000007733 },
segment_details: { segment_name: "DataStore", id: 2136000000008572 },
expires_in: "Aug 18, 2021 06:46 PM",
expiry_in_hours: 47,
ttl_in_milliseconds: 172511000
}
最終更新日 2026-02-23 18:09:41 +0530 IST
Yes
No
Send your feedback to us
Skip
Submit