Skip to content

Commit e0f4531

Browse files
pgajek20ptaq0
andauthored
SOQL Cache (#140)
* SOQL Cache [Draft] (#137) * Cannot modify a collection while it is being iterated Fix (#133) * Cannot modify a collection while it is being iterated Fix Signed-off-by: Piotr PG Gajek <[email protected]> * Code refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * groupByWithDefaultFieldsAndAggregateFunction unit test Signed-off-by: Piotr PG Gajek <[email protected]> --------- Signed-off-by: Piotr PG Gajek <[email protected]> * Cache Init Signed-off-by: Piotr PG Gajek <[email protected]> * draft Signed-off-by: Piotr PG Gajek <[email protected]> * draft Signed-off-by: Piotr PG Gajek <[email protected]> * Cache Concept Signed-off-by: Piotr PG Gajek <[email protected]> * Cache SOQL Examples Signed-off-by: Piotr PG Gajek <[email protected]> * Cache refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * caching draft Signed-off-by: Piotr PG Gajek <[email protected]> * final draft Signed-off-by: Piotr PG Gajek <[email protected]> * SQOL Cache Signed-off-by: Piotr PG Gajek <[email protected]> * refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * SOQLCache Signed-off-by: Piotr PG Gajek <[email protected]> * SOQLCache_Test Signed-off-by: Piotr PG Gajek <[email protected]> * SOQLCache_Test Signed-off-by: Piotr PG Gajek <[email protected]> * SOQLCache_Test Signed-off-by: Piotr PG Gajek <[email protected]> * docs placeholder Signed-off-by: Piotr PG Gajek <[email protected]> * Documentation Signed-off-by: Piotr PG Gajek <[email protected]> * handlefiltering Signed-off-by: Piotr PG Gajek <[email protected]> * refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * Additional methods Signed-off-by: Piotr PG Gajek <[email protected]> * cache mocking Signed-off-by: Piotr PG Gajek <[email protected]> * Examples Signed-off-by: Piotr PG Gajek <[email protected]> * stucture changes Signed-off-by: Piotr PG Gajek <[email protected]> * Fix unit tests Signed-off-by: Piotr PG Gajek <[email protected]> * Unit Test Fix Signed-off-by: Piotr PG Gajek <[email protected]> * Cache Fixes Signed-off-by: Piotr PG Gajek <[email protected]> * SOQLCache_Test Signed-off-by: Piotr PG Gajek <[email protected]> * toObjectWithMultipleRows Signed-off-by: Piotr PG Gajek <[email protected]> * Default Sharing for cached selector Signed-off-by: Piotr PG Gajek <[email protected]> * SOQLCache_Test Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * website update Signed-off-by: Piotr PG Gajek <[email protected]> * mermaid Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * toId() (#139) Signed-off-by: Piotr PG Gajek <[email protected]> * soql cache Signed-off-by: Piotr PG Gajek <[email protected]> * Documentation Signed-off-by: Piotr PG Gajek <[email protected]> * Fix Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * SOQL Cache Test Signed-off-by: Piotr PG Gajek <[email protected]> * SOQLCacheTest Signed-off-by: Piotr PG Gajek <[email protected]> * PMD Signed-off-by: Piotr PG Gajek <[email protected]> * Refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * License Signed-off-by: Piotr PG Gajek <[email protected]> * Fix Unit Tests Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * documentation update Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * refactoring Signed-off-by: Piotr PG Gajek <[email protected]> * documentation 3.7.0 Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * mermaid Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> * documentation Signed-off-by: Piotr PG Gajek <[email protected]> --------- Signed-off-by: Piotr PG Gajek <[email protected]> * SOQLCache_Test Fix Signed-off-by: Piotr PG Gajek <[email protected]> * fixed failing Platform Cache Signed-off-by: Maciej Ptak <[email protected]> --------- Signed-off-by: Piotr PG Gajek <[email protected]> Signed-off-by: Maciej Ptak <[email protected]> Co-authored-by: Maciej Ptak <[email protected]>
1 parent 1c59f1e commit e0f4531

File tree

81 files changed

+17731
-17258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+17731
-17258
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 BeyondTheCloud.Dev
3+
Copyright (c) 2025 BeyondTheCloud.Dev
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Read about the features in the [documentation](https://soql-lib.vercel.app/docs/
9797
6. **Avoid query duplicates**
9898
7. **The default configuration for all queries**
9999
8. **Dynamic conditions**
100+
9. **Cache records**
100101

101102
----
102103

@@ -107,4 +108,4 @@ Read about the features in the [documentation](https://soql-lib.vercel.app/docs/
107108
## License notes
108109

109110
- For proper license management each repository should contain LICENSE file similar to this one.
110-
- Each original class should contain copyright mark: Copyright (c) 2023 BeyondTheCloud.Dev
111+
- Each original class should contain copyright mark: Copyright (c) 2025 Beyond The Cloud Sp. z o.o. (BeyondTheCloud.Dev)

config/project-scratch-def.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"edition": "Developer",
44
"features": [
55
"EnableSetPasswordInApi",
6-
"PersonAccounts"
6+
"PersonAccounts",
7+
"PlatformCache"
78
],
89
"settings": {
910
"lightningExperienceSettings": {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<PlatformCachePartition xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<isDefaultPartition>false</isDefaultPartition>
4+
<masterLabel>SOQL</masterLabel>
5+
<platformCachePartitionTypes>
6+
<allocatedCapacity>1</allocatedCapacity>
7+
<allocatedPartnerCapacity>0</allocatedPartnerCapacity>
8+
<allocatedPurchasedCapacity>0</allocatedPurchasedCapacity>
9+
<allocatedTrialCapacity>0</allocatedTrialCapacity>
10+
<cacheType>Organization</cacheType>
11+
</platformCachePartitionTypes>
12+
<platformCachePartitionTypes>
13+
<allocatedCapacity>1</allocatedCapacity>
14+
<allocatedPartnerCapacity>0</allocatedPartnerCapacity>
15+
<allocatedPurchasedCapacity>0</allocatedPurchasedCapacity>
16+
<allocatedTrialCapacity>0</allocatedTrialCapacity>
17+
<cacheType>Session</cacheType>
18+
</platformCachePartitionTypes>
19+
</PlatformCachePartition>

force-app/main/default/classes/example/ExampleController.cls renamed to force-app/main/default/classes/examples/ExampleController.cls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
public with sharing class ExampleController {
2-
32
@AuraEnabled
43
public static List<Contact> getContactsByRecordType(String recordType) {
54
return SOQL_Contact.query()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public with sharing class SOQL_BusinessHoursCache extends SOQLCache implements SOQLCache.Selector {
2+
public static SOQL_BusinessHoursCache query() {
3+
return new SOQL_BusinessHoursCache();
4+
}
5+
6+
private SOQL_BusinessHoursCache() {
7+
super(BusinessHours.SObjectType);
8+
cacheInOrgCache();
9+
with(BusinessHours.Id, BusinessHours.Name);
10+
}
11+
12+
public override SOQL.Queryable initialQuery() {
13+
return SOQL.of(BusinessHours.SObjectType).whereAre(SOQL.Filter.with(BusinessHours.IsActive).isTrue());
14+
}
15+
16+
public SOQL_BusinessHoursCache byName(String name) {
17+
whereEqual(BusinessHours.Name, name);
18+
return this;
19+
}
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public with sharing class SOQL_OrgWideEmailAddressCache extends SOQLCache implements SOQLCache.Selector {
2+
public static SOQL_OrgWideEmailAddressCache query() {
3+
return new SOQL_OrgWideEmailAddressCache();
4+
}
5+
6+
private SOQL_OrgWideEmailAddressCache() {
7+
super(OrgWideEmailAddress.SObjectType);
8+
with(OrgWideEmailAddress.Id, OrgWideEmailAddress.DisplayName, OrgWideEmailAddress.Address);
9+
}
10+
11+
public override SOQL.Queryable initialQuery() {
12+
return SOQL.of(OrgWideEmailAddress.SObjectType);
13+
}
14+
15+
public SOQL_OrgWideEmailAddressCache byAddress(String address) {
16+
whereEqual(OrgWideEmailAddress.Address, address);
17+
return this;
18+
}
19+
}

0 commit comments

Comments
 (0)