Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions force-app/main/default/classes/cached-soql/SOQLCache.cls
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,16 @@ public virtual inherited sharing class SOQLCache implements Cacheable {
private CacheManager.Cacheable storage = CacheManager.ApexTransaction;
private String cacheKey;

public List<CacheItem> cachedItems {
get {
if (cachedItems == null) {
cachedItems = this.getCachedRecords();
}
return cachedItems;
}
private set;
}

public CacheStorageProxy(String ofObject) {
this.cacheKey = this.getAlphanumericKeyFromObjectApiName(ofObject);
}
Expand All @@ -376,6 +386,10 @@ public virtual inherited sharing class SOQLCache implements Cacheable {
return Pattern.compile('[^a-zA-Z0-9]').matcher(ofObject).replaceAll('');
}

private List<CacheItem> getCachedRecords() {
return (List<CacheItem>) (this.storage.get(this.cacheKey) ?? new List<CacheItem>());
}

public CacheStorageProxy apexTransaction() {
this.storage = CacheManager.ApexTransaction;
return this;
Expand Down Expand Up @@ -409,12 +423,8 @@ public virtual inherited sharing class SOQLCache implements Cacheable {
return this.storage.contains(this.cacheKey);
}

public List<CacheItem> getCachedRecords() {
return (List<CacheItem>) (this.storage.get(this.cacheKey) ?? new List<CacheItem>());
}

public void addRecordsToCache(List<SObject> recordsToAdd) {
List<CacheItem> allCachedRecords = getCachedRecords();
List<CacheItem> allCachedRecords = cachedItems;

for (SObject databaseRecord : recordsToAdd) {
allCachedRecords.add(new CacheItem(databaseRecord));
Expand All @@ -424,7 +434,7 @@ public virtual inherited sharing class SOQLCache implements Cacheable {
}

public void updateRecordsInCache(List<SObject> recordsToUpdate) {
List<CacheItem> allCachedRecords = getCachedRecords();
List<CacheItem> allCachedRecords = cachedItems;

Map<Id, SObject> updatedRecordsById = new Map<Id, SObject>(recordsToUpdate);

Expand All @@ -443,7 +453,7 @@ public virtual inherited sharing class SOQLCache implements Cacheable {

List<CacheItem> filteredCachedItems = new List<CacheItem>();

for (CacheItem cachedRecord : getCachedRecords()) {
for (CacheItem cachedRecord : cachedItems) {
if (!recordsToRemoveIds.contains(cachedRecord.id)) {
filteredCachedItems.add(cachedRecord);
}
Expand All @@ -469,7 +479,7 @@ public virtual inherited sharing class SOQLCache implements Cacheable {
private List<CacheItem> cachedItemsThatMeetCriteria {
get {
if (this.cachedItemsThatMeetCriteria == null) {
this.cachedItemsThatMeetCriteria = this.filterGroup.filter(this.storage.getCachedRecords());
this.cachedItemsThatMeetCriteria = this.filterGroup.filter(this.storage.cachedItems);
}
return this.cachedItemsThatMeetCriteria;
}
Expand Down
26 changes: 18 additions & 8 deletions package/main/default/classes/cached-soql/SOQLCache.cls
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
private CacheManager.Cacheable storage = CacheManager.ApexTransaction;
private String cacheKey;

public List<CacheItem> cachedItems {
get {
if (cachedItems == null) {
cachedItems = this.getCachedRecords();
}
return cachedItems;
}
private set;
}

public CacheStorageProxy(String ofObject) {
this.cacheKey = this.getAlphanumericKeyFromObjectApiName(ofObject);
}
Expand All @@ -331,6 +341,10 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
return Pattern.compile('[^a-zA-Z0-9]').matcher(ofObject).replaceAll('');
}

private List<CacheItem> getCachedRecords() {
return (List<CacheItem>) (this.storage.get(this.cacheKey) ?? new List<CacheItem>());
}

public CacheStorageProxy apexTransaction() {
this.storage = CacheManager.ApexTransaction;
return this;
Expand Down Expand Up @@ -364,12 +378,8 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
return this.storage.contains(this.cacheKey);
}

public List<CacheItem> getCachedRecords() {
return (List<CacheItem>) (this.storage.get(this.cacheKey) ?? new List<CacheItem>());
}

public void addRecordsToCache(List<SObject> recordsToAdd) {
List<CacheItem> allCachedRecords = getCachedRecords();
List<CacheItem> allCachedRecords = cachedItems;

for (SObject databaseRecord : recordsToAdd) {
allCachedRecords.add(new CacheItem(databaseRecord));
Expand All @@ -379,7 +389,7 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
}

public void updateRecordsInCache(List<SObject> recordsToUpdate) {
List<CacheItem> allCachedRecords = getCachedRecords();
List<CacheItem> allCachedRecords = cachedItems;

Map<Id, SObject> updatedRecordsById = new Map<Id, SObject>(recordsToUpdate);

Expand All @@ -398,7 +408,7 @@ global virtual inherited sharing class SOQLCache implements Cacheable {

List<CacheItem> filteredCachedItems = new List<CacheItem>();

for (CacheItem cachedRecord : getCachedRecords()) {
for (CacheItem cachedRecord : cachedItems) {
if (!recordsToRemoveIds.contains(cachedRecord.id)) {
filteredCachedItems.add(cachedRecord);
}
Expand All @@ -424,7 +434,7 @@ global virtual inherited sharing class SOQLCache implements Cacheable {
private List<CacheItem> cachedItemsThatMeetCriteria {
get {
if (this.cachedItemsThatMeetCriteria == null) {
this.cachedItemsThatMeetCriteria = this.filterGroup.filter(this.storage.getCachedRecords());
this.cachedItemsThatMeetCriteria = this.filterGroup.filter(this.storage.cachedItems);
}
return this.cachedItemsThatMeetCriteria;
}
Expand Down
9 changes: 5 additions & 4 deletions sfdx-project.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"packageDirectories": [
{
"versionName": "SOQL Lib 6.11.0",
"versionNumber": "6.11.0.NEXT",
"versionName": "SOQL Lib 6.11.1",
"versionNumber": "6.11.1.NEXT",
"path": "package",
"default": true,
"package": "SOQL Lib",
Expand Down Expand Up @@ -35,6 +35,7 @@
"SOQL Lib@6.10.0-1": "04tP60000036lIfIAI",
"SOQL Lib@6.10.1-1": "04tP60000036lfFIAQ",
"SOQL Lib@6.10.2-1": "04tP60000038Fo9IAE",
"SOQL Lib@6.11.0-1": "04tP6000003MO5BIAW"
"SOQL Lib@6.11.0-1": "04tP6000003MO5BIAW",
"SOQL Lib@6.11.1-1": "04tP6000003On13IAC"
}
}
}
8 changes: 4 additions & 4 deletions website/docs/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 20
<!--
sf package version create --package "SOQL Lib" --target-dev-hub beyondthecloud-prod --installation-key-bypass --wait 30 --code-coverage

sf package version promote --package "SOQL Lib@6.11.0-1" --target-dev-hub beyondthecloud-prod
sf package version promote --package "SOQL Lib@6.11.1-1" --target-dev-hub beyondthecloud-prod
-->

# Installation
Expand All @@ -15,13 +15,13 @@ sidebar_position: 20

Install the SOQL Lib unlocked package with `btcdev` namespace to your Salesforce environment:

`/packaging/installPackage.apexp?p0=04tP6000003MO5BIAW`
`/packaging/installPackage.apexp?p0=04tP6000003On13IAC`

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04tP6000003MO5BIAW" target="_blank" style={{display: 'inline-block', backgroundColor: '#1976d2', color: 'white', padding: '10px 20px', textDecoration: 'none', borderRadius: '4px', marginRight: '10px'}}>
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04tP6000003On13IAC" target="_blank" style={{display: 'inline-block', backgroundColor: '#1976d2', color: 'white', padding: '10px 20px', textDecoration: 'none', borderRadius: '4px', marginRight: '10px'}}>
<p style={{margin: '0px'}}>Install on Sandbox</p>
</a>

<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04tP6000003MO5BIAW" target="_blank" style={{display: 'inline-block', backgroundColor: '#d32f2f', color: 'white', padding: '10px 20px', textDecoration: 'none', borderRadius: '4px'}}>
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04tP6000003On13IAC" target="_blank" style={{display: 'inline-block', backgroundColor: '#d32f2f', color: 'white', padding: '10px 20px', textDecoration: 'none', borderRadius: '4px'}}>
<p style={{margin: '0px'}}>Install on Production</p>
</a>

Expand Down
Loading