Skip to content

Commit 1002d9a

Browse files
committed
invalidateRecords documentation
Signed-off-by: Piotr PG Gajek <[email protected]>
1 parent 850a0fc commit 1002d9a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

website/docs/api/cached-soql/soql-cache.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The following are methods for using `SOQLCache`:
2929
[**CACHE EXPIRATION**](#cache-expiration)
3030

3131
- [`maxHoursWithoutRefresh()`](#maxhourswithoutrefresh)
32+
- [`invalidateRecords(List<SObject> records)`](#invalidaterecords)
3233

3334
[**INITIAL QUERY**](#initial-query)
3435

@@ -182,6 +183,24 @@ SOQLCache.of(Profile.SObjectType)
182183
.toObject();
183184
```
184185

186+
### invalidateRecords
187+
188+
The `invalidateRecords` method allows clearing records from the cache, triggering an automatic refresh the next time the query is executed.
189+
190+
**Signature**
191+
192+
```apex
193+
Cacheable invalidateRecords(List<SObject> records)
194+
```
195+
196+
**Example**
197+
198+
```apex
199+
trigger SomeObjectTrigger on SomeObject (after update, after delete) {
200+
SOQLCache.invalidateRecords(Trigger.old);
201+
}
202+
```
203+
185204
## INITIAL QUERY
186205

187206
The initial query allows for the bulk population of records in the cache (if it is empty), ensuring that every subsequent query in the cached selector will use the cached records.

0 commit comments

Comments
 (0)