Skip to content

Commit fb14864

Browse files
jongpiejamessimone
andauthored
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]>
1 parent e69549e commit fb14864

File tree

43 files changed

+26008
-5499
lines changed

Some content is hidden

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

43 files changed

+26008
-5499
lines changed

.forceignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ package.xml
99
**/.eslintrc.json
1010

1111
# LWC Jest
12-
**/__tests__/**
12+
**/__tests__/**
13+
14+
# Metadata
15+
**.profile-meta.xml

.gitattributes

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Set the default line return behavior, in case people don't have core.autocrlf set.
2+
* text=auto eol=lf
3+
4+
# Common git file types
5+
.gitattributes text eol=lf
6+
.gitignore text eol=lf
7+
*.md text eol=lf
8+
9+
# Salesforce-specfic file types
10+
*.app text eol=lf
11+
*.cls text eol=lf
12+
*.cmp text eol=lf
13+
*.component text eol=lf
14+
*.css text eol=lf
15+
*.html text eol=lf
16+
*.js text eol=lf
17+
*.page text eol=lf
18+
*.trigger text eol=lf
19+
*.xml text eol=lf
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
name: Fetch Repo Stats
22

33
on:
4-
schedule:
5-
# Run this once per day, towards the end of the day for keeping the most
6-
# recent data point most meaningful (hours are interpreted in UTC).
7-
- cron: '0 23 * * *'
8-
workflow_dispatch: # Allow for running this manually.
4+
schedule:
5+
# Run this once per day, towards the end of the day for keeping the most
6+
# recent data point most meaningful (hours are interpreted in UTC).
7+
- cron: '0 23 * * *'
8+
workflow_dispatch: # Allow for running this manually.
99

1010
jobs:
11-
j1:
12-
name: store-repo-stats
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: run-ghrs
16-
uses: jgehrcke/github-repo-stats@RELEASE
17-
with:
18-
ghtoken: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
11+
j1:
12+
name: store-repo-stats
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: run-ghrs
16+
uses: jgehrcke/github-repo-stats@RELEASE
17+
with:
18+
ghtoken: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ deploy-options.json
1212
# LWC VSCode autocomplete
1313
**/lwc/jsconfig.json
1414

15-
# LWC Jest coverage reports
16-
coverage/
15+
# Code coverage reports
16+
test-coverage/
17+
18+
# Salesforce metadata
19+
**/customMetadata/CacheValue.**.md-meta.xml
20+
**.profile-meta.xml
1721

1822
# Logs
1923
logs

.prettierignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
#
44

55
**/staticresources/**
6-
.localdevserver
7-
.sfdx
8-
.vscode
9-
10-
coverage/
6+
.localdevserver/
7+
.sf/
8+
.sfdx/
9+
.husky/
10+
coverage/
11+
node_modules/

.prettierrc

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
{
2-
"tabWidth": 2,
2+
"arrowParens": "avoid",
33
"printWidth": 160,
4-
"overrides": [
5-
{
6-
"files": "**/lwc/**/*.html",
7-
"options": { "parser": "lwc" }
8-
},
9-
{
10-
"files": "*.{cmp,page,component}",
11-
"options": { "parser": "html" }
12-
}
13-
]
14-
}
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "none"
7+
}

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
# Apex Cache Manager
1+
# Nebula Cache Manager
2+
3+
A flexible cache management system for Salesforce Apex developers. Built to be scalable & configurable.
4+
5+
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/)
6+
7+
## Unlocked Package - `Nebula` Namespace - v1.0.0
8+
9+
[![Install Unlocked Package (Nebula namespace) in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015n2AQAQ)
10+
[![Install Unlocked Package (Nebula namespace) in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015n2AQAQ)
11+
12+
## Unlocked Package - No Namespace - v1.0.0
13+
14+
[![Install Unlocked Package (no namespace) in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015n25QAA)
15+
[![Install Unlocked Package (no namespace) in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015n25QAA)
16+
17+
---
18+
19+
## Cache Manager for Apex: Quick Start
20+
21+
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.
22+
23+
```java
24+
// This will cache a Map<String, Group> that contains all queues in the current org (if the data has not been cached)
25+
// or it will return the cached version of the data (if the data has previously been cached)
26+
public static Map<String, Group> getQueues() {
27+
String cacheKey = 'queues';
28+
Map<String, Group> queueDeveloperNameToQueueGroup;
29+
if (CacheManager.getOrganization().contains(cacheKey)) {
30+
queueDeveloperNameToQueueGroup = (Map<String, Group>) CacheManager.getOrganization().get(cacheKey);
31+
} else {
32+
queueDeveloperNameToQueueGroup = new Map<String, Group>();
33+
for (Group queueGroup : [SELECT Id, DeveloperName, Email, Name FROM Group WHERE Type = 'Queue']) {
34+
queueDeveloperNameToQueueGroup.put(queueGroup.DeveloperName, queueGroup);
35+
}
36+
CacheManager.getOrganization().put(cacheKey, queueDeveloperNameToQueueGroup);
37+
}
38+
return queueDeveloperNameToQueueGroup;
39+
}
40+
```

config/linters/pmd-ruleset.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" ?>
2+
<ruleset
3+
name="Nebula Cache Manager Rules"
4+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"
7+
>
8+
<description>
9+
Nebula Cache Manager custom PMD ruleset
10+
</description>
11+
<rule ref="category/apex/bestpractices.xml">
12+
</rule>
13+
<rule ref="category/apex/codestyle.xml">
14+
</rule>
15+
<rule ref="category/apex/design.xml">
16+
</rule>
17+
<rule ref="category/apex/documentation.xml">
18+
</rule>
19+
<rule ref="category/apex/errorprone.xml">
20+
</rule>
21+
<rule ref="category/apex/performance.xml">
22+
</rule>
23+
<rule ref="category/apex/security.xml">
24+
</rule>
25+
</ruleset>

config/project-scratch-def.json

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"orgName": "Nebula Cache Manager - Base Scratch Org",
3+
"edition": "Enterprise",
4+
"hasSampleData": true,
5+
"country": "US",
6+
"language": "en_US",
7+
"features": [],
8+
"settings": {
9+
"securitySettings": {
10+
"enableAdminLoginAsAnyUser": false
11+
},
12+
"userManagementSettings": {
13+
"enableEnhancedPermsetMgmt": true,
14+
"enableEnhancedProfileMgmt": true,
15+
"enableNewProfileUI": true
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)