Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jongpie/nebulacachemanager
A flexible cache management system for Salesforce Apex developers. Built to be scalable & configurable.
https://github.com/jongpie/nebulacachemanager
apex caching salesforce salesforce-admins salesforce-cache salesforce-developers
Last synced: 27 days ago
JSON representation
A flexible cache management system for Salesforce Apex developers. Built to be scalable & configurable.
- Host: GitHub
- URL: https://github.com/jongpie/nebulacachemanager
- Owner: jongpie
- License: mit
- Created: 2022-12-21T21:31:23.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-01T23:06:35.000Z (8 months ago)
- Last Synced: 2024-05-02T05:43:06.653Z (8 months ago)
- Topics: apex, caching, salesforce, salesforce-admins, salesforce-cache, salesforce-developers
- Language: Apex
- Homepage:
- Size: 48.2 MB
- Stars: 28
- Watchers: 3
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.2
[![Install Unlocked Package (Nebula namespace) in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015nCfQAI)
[![Install Unlocked Package (Nebula namespace) in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015nCfQAI)## Unlocked Package - No Namespace - v1.0.2
[![Install Unlocked Package (no namespace) in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015nCaQAI)
[![Install Unlocked Package (no namespace) in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015nCaQAI)---
## 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 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 getQueues() {
String cacheKey = 'queues';
Map queueDeveloperNameToQueueGroup;
if (CacheManager.getOrganization().contains(cacheKey)) {
queueDeveloperNameToQueueGroup = (Map) CacheManager.getOrganization().get(cacheKey);
} else {
queueDeveloperNameToQueueGroup = new Map();
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;
}
```