Invalidate NEAR index caches from block effects
Refreshing every watched contract on every block wastes RPC capacity. The block-effects summary identifies accounts and categories of state touched in one block.
Mark affected cache entries
Pass the finalized block hash from your block consumer. A data_touched entry for shop.testnet can invalidate cached contract views depending on that state. A contract_code_touched entry can invalidate the decoder or interface assumption for that account.
{
"jsonrpc": "2.0",
"id": 1,
"method": "block_effects",
"params": {
"block_id": "FINALIZED_BLOCK_HASH"
}
}
Fetch replacement values at the same block
The summary reports affected categories. To reconstruct exact storage deltas, issue changes with changes_type data_changes, account_ids, the key prefix and the same block_id. If only a computed contract view is cached, issue that view at the same hash instead.
Keep the last processed block separately from cache freshness. If refreshing one account fails, mark it stale and retry that block’s read without republishing a value from a newer head under the older block hash.