-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial release + Joys of Apex article (#1)
* Created new project based Nebula Logger's cache class as a standalone version, CacheManager * Provided more developer controls for caching by adding several new methods to the interface CacheManager.Cacheable * Provided more configuration options for caching via CacheConfiguration__mdt and CacheValue__mdt custom metadata types * Created namespaced (`Nebula`) and no-namespace 2GP unlocked packages * Added link to a new Joys of Apex article that walks through iteratively expanding upon the CacheManager class - https://www.jamessimone.net/blog/joys-of-apex/iteratively-building-a-flexible-caching-system/ --------- Co-authored-by: James Simone <[email protected]>
- Loading branch information
1 parent
e69549e
commit fb14864
Showing
43 changed files
with
26,008 additions
and
5,499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,7 @@ package.xml | |
**/.eslintrc.json | ||
|
||
# LWC Jest | ||
**/__tests__/** | ||
**/__tests__/** | ||
|
||
# Metadata | ||
**.profile-meta.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Set the default line return behavior, in case people don't have core.autocrlf set. | ||
* text=auto eol=lf | ||
|
||
# Common git file types | ||
.gitattributes text eol=lf | ||
.gitignore text eol=lf | ||
*.md text eol=lf | ||
|
||
# Salesforce-specfic file types | ||
*.app text eol=lf | ||
*.cls text eol=lf | ||
*.cmp text eol=lf | ||
*.component text eol=lf | ||
*.css text eol=lf | ||
*.html text eol=lf | ||
*.js text eol=lf | ||
*.page text eol=lf | ||
*.trigger text eol=lf | ||
*.xml text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
name: Fetch Repo Stats | ||
|
||
on: | ||
schedule: | ||
# Run this once per day, towards the end of the day for keeping the most | ||
# recent data point most meaningful (hours are interpreted in UTC). | ||
- cron: '0 23 * * *' | ||
workflow_dispatch: # Allow for running this manually. | ||
schedule: | ||
# Run this once per day, towards the end of the day for keeping the most | ||
# recent data point most meaningful (hours are interpreted in UTC). | ||
- cron: '0 23 * * *' | ||
workflow_dispatch: # Allow for running this manually. | ||
|
||
jobs: | ||
j1: | ||
name: store-repo-stats | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: run-ghrs | ||
uses: jgehrcke/github-repo-stats@RELEASE | ||
with: | ||
ghtoken: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
j1: | ||
name: store-repo-stats | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: run-ghrs | ||
uses: jgehrcke/github-repo-stats@RELEASE | ||
with: | ||
ghtoken: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
{ | ||
"tabWidth": 2, | ||
"arrowParens": "avoid", | ||
"printWidth": 160, | ||
"overrides": [ | ||
{ | ||
"files": "**/lwc/**/*.html", | ||
"options": { "parser": "lwc" } | ||
}, | ||
{ | ||
"files": "*.{cmp,page,component}", | ||
"options": { "parser": "html" } | ||
} | ||
] | ||
} | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
# Apex Cache Manager | ||
# Nebula Cache Manager | ||
|
||
A flexible cache management system for Salesforce Apex developers. Built to be scalable & configurable. | ||
|
||
Learn more about the history & implementation of this repo in [the Joys of Apex article 'Iteratively Building a Flexible Caching System for Apex'](https://www.jamessimone.net/blog/joys-of-apex/iteratively-building-a-flexible-caching-system/) | ||
|
||
## Unlocked Package - `Nebula` Namespace - v1.0.0 | ||
|
||
[![Install Unlocked Package (Nebula namespace) in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015n2AQAQ) | ||
[![Install Unlocked Package (Nebula namespace) in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015n2AQAQ) | ||
|
||
## Unlocked Package - No Namespace - v1.0.0 | ||
|
||
[![Install Unlocked Package (no namespace) in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015n25QAA) | ||
[![Install Unlocked Package (no namespace) in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015n25QAA) | ||
|
||
--- | ||
|
||
## Cache Manager for Apex: Quick Start | ||
|
||
For Apex developers, the `CacheManager` class has several methods that can be used to cache data in 1 of the 3 supported cache types - transaction, organization platform cache, and session platform cache. Each cache type implements the interface `CacheManager.Cacheable` - regardless of which cache type you choose, the way you interact with each cache type is consistent. | ||
|
||
```java | ||
// This will cache a Map<String, Group> that contains all queues in the current org (if the data has not been cached) | ||
// or it will return the cached version of the data (if the data has previously been cached) | ||
public static Map<String, Group> getQueues() { | ||
String cacheKey = 'queues'; | ||
Map<String, Group> queueDeveloperNameToQueueGroup; | ||
if (CacheManager.getOrganization().contains(cacheKey)) { | ||
queueDeveloperNameToQueueGroup = (Map<String, Group>) CacheManager.getOrganization().get(cacheKey); | ||
} else { | ||
queueDeveloperNameToQueueGroup = new Map<String, Group>(); | ||
for (Group queueGroup : [SELECT Id, DeveloperName, Email, Name FROM Group WHERE Type = 'Queue']) { | ||
queueDeveloperNameToQueueGroup.put(queueGroup.DeveloperName, queueGroup); | ||
} | ||
CacheManager.getOrganization().put(cacheKey, queueDeveloperNameToQueueGroup); | ||
} | ||
return queueDeveloperNameToQueueGroup; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" ?> | ||
<ruleset | ||
name="Nebula Cache Manager Rules" | ||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd" | ||
> | ||
<description> | ||
Nebula Cache Manager custom PMD ruleset | ||
</description> | ||
<rule ref="category/apex/bestpractices.xml"> | ||
</rule> | ||
<rule ref="category/apex/codestyle.xml"> | ||
</rule> | ||
<rule ref="category/apex/design.xml"> | ||
</rule> | ||
<rule ref="category/apex/documentation.xml"> | ||
</rule> | ||
<rule ref="category/apex/errorprone.xml"> | ||
</rule> | ||
<rule ref="category/apex/performance.xml"> | ||
</rule> | ||
<rule ref="category/apex/security.xml"> | ||
</rule> | ||
</ruleset> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"orgName": "Nebula Cache Manager - Base Scratch Org", | ||
"edition": "Enterprise", | ||
"hasSampleData": true, | ||
"country": "US", | ||
"language": "en_US", | ||
"features": [], | ||
"settings": { | ||
"securitySettings": { | ||
"enableAdminLoginAsAnyUser": false | ||
}, | ||
"userManagementSettings": { | ||
"enableEnhancedPermsetMgmt": true, | ||
"enableEnhancedProfileMgmt": true, | ||
"enableNewProfileUI": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"orgName": "Nebula Cache Manager - Base Scratch Org", | ||
"edition": "Enterprise", | ||
"hasSampleData": true, | ||
"country": "US", | ||
"language": "en_US", | ||
"features": ["PlatformCache"], | ||
"settings": { | ||
"securitySettings": { | ||
"enableAdminLoginAsAnyUser": false | ||
}, | ||
"userManagementSettings": { | ||
"enableEnhancedPermsetMgmt": true, | ||
"enableEnhancedProfileMgmt": true, | ||
"enableNewProfileUI": true | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<PlatformCachePartition xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<isDefaultPartition>false</isDefaultPartition> | ||
<masterLabel>CacheManagerPartition</masterLabel> | ||
<platformCachePartitionTypes> | ||
<allocatedCapacity>0</allocatedCapacity> | ||
<allocatedPartnerCapacity>0</allocatedPartnerCapacity> | ||
<allocatedPurchasedCapacity>0</allocatedPurchasedCapacity> | ||
<allocatedTrialCapacity>0</allocatedTrialCapacity> | ||
<cacheType>Session</cacheType> | ||
</platformCachePartitionTypes> | ||
<platformCachePartitionTypes> | ||
<allocatedCapacity>0</allocatedCapacity> | ||
<allocatedPartnerCapacity>0</allocatedPartnerCapacity> | ||
<allocatedPurchasedCapacity>0</allocatedPurchasedCapacity> | ||
<allocatedTrialCapacity>0</allocatedTrialCapacity> | ||
<cacheType>Organization</cacheType> | ||
</platformCachePartitionTypes> | ||
</PlatformCachePartition> |
Oops, something went wrong.