You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All cached records have an additional field called `cachedDate`. To avoid using outdated records, you can configure `maxHoursWithoutRefresh` to automatically refresh stale cache entries:
public inherited sharing class SOQL_CachedProfile extends SOQLCache implements SOQLCache.Selector {
56
56
private SOQL_CachedProfile() {
@@ -66,7 +66,7 @@ public inherited sharing class SOQL_CachedProfile extends SOQLCache implements S
66
66
67
67
Cached selectors extend SOQLCache and provide default cache configurations, fields, and reusable methods. Each cached selector focuses on a single SObjectType with optimal caching strategy.
68
68
69
-
```apex
69
+
```apex title="SOQL_CachedProfile.cls"
70
70
public inherited sharing class SOQL_CachedProfile extends SOQLCache implements SOQLCache.Selector {
71
71
public static SOQL_CachedProfile query() {
72
72
return new SOQL_CachedProfile();
@@ -99,7 +99,7 @@ public inherited sharing class SOQL_CachedProfile extends SOQLCache implements S
@@ -128,7 +128,7 @@ The initial query allows for bulk population of records in the cache when it's e
128
128
**Design Philosophy:**
129
129
When the cache is empty, execute a single query to populate all commonly used records. This dramatically reduces the number of database queries for frequently accessed data like Profiles, BusinessHours, or OrgWideEmailAddress.
130
130
131
-
```apex
131
+
```apex title="SOQL_CachedProfile.cls"
132
132
public inherited sharing class SOQL_CachedProfile extends SOQLCache implements SOQLCache.Selector {
133
133
private SOQL_CachedProfile() {
134
134
super(Profile.SObjectType);
@@ -147,7 +147,7 @@ public inherited sharing class SOQL_CachedProfile extends SOQLCache implements S
147
147
**How It Works:**
148
148
When `SOQL_CachedProfile.query().byName('System Administrator').toObject()` is called and the cache is empty, the initial query executes to populate ALL profiles in cache. Subsequent queries retrieve from cache without hitting the database.
149
149
150
-
```apex
150
+
```apex title="ExampleController.cls"
151
151
public with sharing class ExampleController {
152
152
@AuraEnabled
153
153
public static Id getSystemAdminProfileId() {
@@ -175,7 +175,7 @@ Unlike standard SOQL queries that use `WITH USER_MODE`, cached records require t
175
175
176
176
The `Security.stripInaccessible` method is the only FLS method that works with cached records, as it can remove inaccessible fields from already retrieved data.
@@ -201,15 +201,15 @@ Cached queries have specific filtering requirements to ensure data consistency a
201
201
202
202
By default, cached queries can only filter by unique fields (`Id`, `Name`, `DeveloperName`, or schema-defined unique fields). This prevents inconsistencies between cached and database records.
0 commit comments