From 30171a8f9e5cab4fc2c2e7be9dd568191c4fccce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wo=C5=BAniak?= Date: Wed, 11 Sep 2024 17:40:10 +0200 Subject: [PATCH 1/2] Update metadata to API v61 (files were pulled form org) Add Apex Docs to CacheManager.cls based on similar Nebula logger class and own understanding Renamed PlatformCacheType to PlatformCachePartitionType in CacheManager.cls to align it with Nebula Logger class. Add debug messages in case cache partition is not found to help in case of debugging. Add description to cache CacheManagerPartition.cachePartition-meta.xml Changed package version to 1.0.3 --- ...heManagerPartition.cachePartition-meta.xml | 3 +- .../core/classes/CacheManager.cls | 161 ++++++++++++++++-- .../core/classes/CacheManager.cls-meta.xml | 4 +- .../core/classes/CacheManager_Tests.cls | 62 +++---- .../classes/CacheManager_Tests.cls-meta.xml | 4 +- ...acheConfiguration.Organization.md-meta.xml | 8 +- .../CacheConfiguration.Session.md-meta.xml | 8 +- ...CacheConfiguration.Transaction.md-meta.xml | 12 +- ...Cache Configuration Layout.layout-meta.xml | 8 +- ...ue__mdt-Cache Value Layout.layout-meta.xml | 8 +- .../CacheConfiguration__mdt.object-meta.xml | 2 +- .../fields/IsEnabled__c.field-meta.xml | 3 +- .../fields/IsImmutable__c.field-meta.xml | 6 +- ...atformCachePartitionName__c.field-meta.xml | 2 +- .../PlatformCacheTimeToLive__c.field-meta.xml | 2 +- .../PlatformCacheVisibility__c.field-meta.xml | 3 +- .../listViews/All.listView-meta.xml | 2 +- .../CacheValue__mdt.object-meta.xml | 2 +- .../fields/Cache__c.field-meta.xml | 3 +- .../fields/DataType__c.field-meta.xml | 5 +- .../fields/IsEnabled__c.field-meta.xml | 3 +- .../fields/Key__c.field-meta.xml | 2 +- .../fields/Value__c.field-meta.xml | 3 +- .../listViews/All.listView-meta.xml | 2 +- ...MustBeAlphanumeric.validationRule-meta.xml | 2 +- .../CacheManagerAdmin.permissionset-meta.xml | 2 +- .../classes/RecordSelector.cls-meta.xml | 4 +- package.json | 2 +- sfdx-project.json | 6 +- 29 files changed, 226 insertions(+), 108 deletions(-) diff --git a/nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml b/nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml index a5718ead..c4ef8704 100644 --- a/nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml +++ b/nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml @@ -1,5 +1,6 @@ - + + Platform cache partition used by Nebula Cache Manager false CacheManagerPartition diff --git a/nebula-cache-manager/core/classes/CacheManager.cls b/nebula-cache-manager/core/classes/CacheManager.cls index b7bc787c..97eaee3c 100644 --- a/nebula-cache-manager/core/classes/CacheManager.cls +++ b/nebula-cache-manager/core/classes/CacheManager.cls @@ -3,16 +3,20 @@ // See LICENSE file or go to https://github.com/jongpie/NebulaCacheManager for full license details. // //---------------------------------------------------------------------------------------------------// -@SuppressWarnings('PMD.ApexDoc, PMD.AvoidDebugStatements, PMD.AvoidGlobalModifier, PMD.ExcessivePublicCount, PMD.PropertyNamingConventions') +@SuppressWarnings('PMD.ApexDoc, PMD.AvoidDebugStatements, PMD.AvoidGlobalModifier, PMD.ExcessivePublicCount, PMD.PropertyNamingConventions, PMD.CognitiveComplexity') global without sharing class CacheManager { @TestVisible private static final Map CONFIGURATION_DEVELOPER_NAME_TO_CACHEABLE_INSTANCE = new Map(); @TestVisible - private static final List CONFIGURED_CACHE_VALUES = Schema.CacheValue__mdt.getAll().values(); - @TestVisible - private static final String CURRENT_VERSION_NUMBER = 'v1.0.2'; + private static final String CURRENT_VERSION_NUMBER = 'v1.0.3'; @TestVisible private static final String PLATFORM_CACHE_NULL_VALUE = '<{(CACHE_VALUE_IS_NULL)}>'; // Presumably, no one will ever use this as an actual value + + // Load predefined cache values from "Cache Value" custom metadata. They will be always available in cache. + @TestVisible + private static final List CONFIGURED_CACHE_VALUES = Schema.CacheValue__mdt.getAll().values(); + + // Load partitions configurations from "Cache Configuration" custom metadata. @TestVisible private static final CacheConfiguration__mdt ORGANIZATION_CACHE_CONFIGURATION = Schema.CacheConfiguration__mdt.getInstance('Organization').clone(); @TestVisible @@ -20,7 +24,7 @@ global without sharing class CacheManager { @TestVisible private static final CacheConfiguration__mdt TRANSACTION_CACHE_CONFIGURATION = Schema.CacheConfiguration__mdt.getInstance('Transaction').clone(); - private static Map cacheTypeToMockPartitionProxy = new Map(); + private static Map cacheTypeToMockPartitionProxy = new Map(); private static final System.Pattern ALPHANUMERIC_REGEX_PATTERN { get { @@ -37,46 +41,162 @@ global without sharing class CacheManager { } @TestVisible - private enum PlatformCacheType { + private enum PlatformCachePartitionType { ORGANIZATION, SESSION } + /** + * @description Interface used to define caches that can be used to store values via different mechanisms + */ global interface Cacheable { + /** + * @description Indicates if the specified key has already been added to the cache + * @param key The `String` key to check for within the cache + * @return The `Boolean` result that indicates if the specified key is contained in the cache + */ Boolean contains(String key); + + /** + * @description Indicates if the specified keys have already been added to the cache + * @param keys The Set of `String` keys to check for within the cache + * @return The `Map` result that indicates if the specified key is contained in the cache + */ Map contains(Set keys); + + /** + * @description Indicates if the specified keys have already been added to the cache + * @param keys The Set of `String` keys to check for within the cache + * @return The `Boolean` result that indicates if all given keys are contained in the cache + */ Boolean containsAll(Set keys); + + /** + * @description Returns the cached value for the specified key, or `null` if the specified key does not exist in the cache + * @param key The `String` key to check for within the cache + * @return The `Object` cached value, or `null` if no cached value is found for the specified key + */ Object get(String key); + + /** + * @description Returns the cached value for the specified key, or `null` if the specified key does not exist in the cache + * @param key The `String` key to check for within the cache + * @param cacheBuilderClass Instance of cacheBuilderClass + * @return The cached value, or `null` if no cached value is found for the specified key + */ Object get(String key, System.Type cacheBuilderClass); + + /** + * @description Returns the cached values for the specified keys, or `null` if the specified key does not exist in the cache + * @param keys The Set of `String` keys to check for within the cache + * @return The `Map` with cached value, or `null` if no cached value is found for the specified key + */ Map get(Set keys); + + /** + * @description Returns all cached values + * @return The `Map` with all cached values + */ Map getAll(); + + /** + * @description Returns all Keys stored in cache. + * @return `Set` with all keys of cache entries. + */ Set getKeys(); + + /** + * @description Check if cache is Available for use (enabled and configured) + * @return `Boolean` + */ Boolean isAvailable(); + + /** + * @description Check if cache was configured in Custom Metadata as Enabled. + * @return `Boolean` + */ Boolean isEnabled(); + + /** + * @description Check if cache was configured in Custom Metadata as Immutable. + * @return `Boolean` + */ Boolean isImmutable(); + + /** + * @description Adds the provided `Object` value to the cache, using the specified `String` key + * @param key The `String` key to add to the cache + * @param value The `Object` value to cache for the specified key + */ void put(String key, Object value); + + /** + * @description Adds the provided `Object` values to the cache, using the specified `String` keys. + * @param keyToValue The Map of `String` keys to add to the cache with the `Object` values for that keys. + */ void put(Map keyToValue); + + /** + * @description Removes the specified `String` key from the cache + * @param key The `String` key to remove from the cache + */ void remove(String key); + + /** + * @description Removes the specified Set of `String` keys from the cache + * @param keys The Set of `String` keys to remove from the cache + */ void remove(Set keys); + + /** + * @description Removes all keys from cache. Clear cache. + */ void removeAll(); } + /** + * @description The instance of `Cacheable` used for any organization-specific caching via Platform Cache. + * When Platform Cache is disabled or not available, the transaction cache is instead used. + * @return The singleton instance of `Cacheable` + */ global static Cacheable getOrganizationCache() { return getOrganizationCache(ORGANIZATION_CACHE_CONFIGURATION); } + /** + * @description The instance of `Cacheable` used for any organization-specific caching via Platform Cache. + * When Platform Cache is disabled or not available, the transaction cache is instead used. + * @param configuration Configuration stored in Custom Metadata record for Organization Cache + * @return The singleton instance of `Cacheable` + */ global static Cacheable getOrganizationCache(CacheConfiguration__mdt configuration) { - return getPlatformCache(configuration, PlatformCacheType.ORGANIZATION); + return getPlatformCache(configuration, PlatformCachePartitionType.ORGANIZATION); } + /** + * @description The instance of `Cacheable` used for any session-specific caching via Platform Cache. + * When Platform Cache is disabled or not available, the transaction cache is instead used. + * @return The singleton instance of `Cacheable` + */ global static Cacheable getSessionCache() { return getSessionCache(SESSION_CACHE_CONFIGURATION); } + /** + * @description The instance of `Cacheable` used for any organization-specific caching via Platform Cache. + * When Platform Cache is disabled or not available, the transaction cache is instead used. + * @param configuration Configuration stored in Custom Metadata record for Session Cache + * @return The singleton instance of `Cacheable` + */ global static Cacheable getSessionCache(CacheConfiguration__mdt configuration) { - return getPlatformCache(configuration, PlatformCacheType.SESSION); + return getPlatformCache(configuration, PlatformCachePartitionType.SESSION); } + /** + * @description The instance of `Cacheable` used for any transaction-specific caching. + * Cached data is stored internally in-memory for the duration of the transaction. + * @return The singleton instance of `Cacheable` + */ global static Cacheable getTransactionCache() { if (CONFIGURATION_DEVELOPER_NAME_TO_CACHEABLE_INSTANCE.containsKey(TRANSACTION_CACHE_CONFIGURATION.DeveloperName)) { return CONFIGURATION_DEVELOPER_NAME_TO_CACHEABLE_INSTANCE.get(TRANSACTION_CACHE_CONFIGURATION.DeveloperName); @@ -89,10 +209,15 @@ global without sharing class CacheManager { } @TestVisible - private static void setMockPartitionProxy(PlatformCacheType cacheType, PlatformCachePartitionProxy mockPartitionProxy) { + private static void setMockPartitionProxy(PlatformCachePartitionType cacheType, PlatformCachePartitionProxy mockPartitionProxy) { cacheTypeToMockPartitionProxy.put(cacheType, mockPartitionProxy); } + /** + * @description Validate if given key is alphanumeric without any special characters. Allowed characters a-z A-Z 0-9 + * @param key String to be checked. + * @exception Exception is thrown if key contains not allowed characters. + */ @TestVisible private static void validateKey(String key) { Matcher regexMatcher = ALPHANUMERIC_REGEX_PATTERN.matcher(key); @@ -101,7 +226,7 @@ global without sharing class CacheManager { } } - private static Cacheable getPlatformCache(CacheConfiguration__mdt configuration, PlatformCacheType cacheType) { + private static Cacheable getPlatformCache(CacheConfiguration__mdt configuration, PlatformCachePartitionType cacheType) { if (CONFIGURATION_DEVELOPER_NAME_TO_CACHEABLE_INSTANCE.containsKey(configuration.DeveloperName)) { return CONFIGURATION_DEVELOPER_NAME_TO_CACHEABLE_INSTANCE.get(configuration.DeveloperName); } @@ -122,6 +247,12 @@ global without sharing class CacheManager { return platformCache; } + /** + * @description Check if given cache type is enabled and load permanent cache values from "Cache Value" custom metadata. + * Values are loaded for given type of Cache and only if they are enabled. + * @param cacheConfiguration Custom Metadata record + * @return `Map` Map of key to cache value. + */ private static Map loadConfiguredCacheValues(CacheConfiguration__mdt cacheConfiguration) { Map keyToCacheValue = new Map(); if (cacheConfiguration.IsEnabled__c == false) { @@ -139,6 +270,10 @@ global without sharing class CacheManager { return keyToCacheValue; } + /** + * @description Manages interacting with platform cache. The provided transaction cache instance is used internally as the primary + * caching method, and is further augmented by using Platform Cache to provide caching that spans multiple transactions. + */ @SuppressWarnings('PMD.CognitiveComplexity, PMD.CyclomaticComplexity') private class PlatformCache implements Cacheable { private final PlatformCachePartitionProxy cachePartitionProxy; @@ -296,7 +431,7 @@ global without sharing class CacheManager { private final Cache.Partition platformCachePartition; @SuppressWarnings('PMD.EmptyCatchBlock') - protected PlatformCachePartitionProxy(PlatformCacheType cacheType, String partitionName) { + protected PlatformCachePartitionProxy(PlatformCachePartitionType cacheType, String partitionName) { // If the specified partition name is not found, the platform automatically throws a runtime exception, which isn't ideal. // It seems better to eat the exceptions & fallback to the transaction cache (which doesn't rely on Platform Cache). try { @@ -309,8 +444,10 @@ global without sharing class CacheManager { } } } catch (Cache.Org.OrgCacheException orgCacheException) { + System.Debug(LoggingLevel.WARN, '@#@ ⚠️ Organization Cache partition named ' + partitionName + ' not found.'); // No-op if the partition can't be found - the rest of the code will fallback to using the transaction cache } catch (Cache.Session.SessionCacheException sessionCacheException) { + System.Debug(LoggingLevel.WARN, '@#@ ⚠️ Session Cache partition named ' + partitionName + ' not found.'); // No-op if the partition can't be found - the rest of the code will fallback to using the transaction cache } } @@ -460,4 +597,4 @@ global without sharing class CacheManager { } } } -} +} \ No newline at end of file diff --git a/nebula-cache-manager/core/classes/CacheManager.cls-meta.xml b/nebula-cache-manager/core/classes/CacheManager.cls-meta.xml index 1248daa8..651b1729 100644 --- a/nebula-cache-manager/core/classes/CacheManager.cls-meta.xml +++ b/nebula-cache-manager/core/classes/CacheManager.cls-meta.xml @@ -1,5 +1,5 @@ - + - 56.0 + 61.0 Active diff --git a/nebula-cache-manager/core/classes/CacheManager_Tests.cls b/nebula-cache-manager/core/classes/CacheManager_Tests.cls index 6c9f97da..3bc8f1ff 100644 --- a/nebula-cache-manager/core/classes/CacheManager_Tests.cls +++ b/nebula-cache-manager/core/classes/CacheManager_Tests.cls @@ -194,7 +194,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getOrganizationCache().contains(mockKey)); System.Assert.areEqual(1, mockOrganizationPartitionProxy.containsMethodCallCount); @@ -216,7 +216,7 @@ private class CacheManager_Tests { MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); mockOrganizationPartitionProxy.put(mockKey, mockValue, 3600, Cache.Visibility.ALL, false); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); System.Assert.isTrue(CacheManager.getOrganizationCache().contains(mockKey)); System.Assert.areEqual(1, mockOrganizationPartitionProxy.containsMethodCallCount); @@ -236,7 +236,7 @@ private class CacheManager_Tests { MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); mockSessionPartitionProxy.put(mockKey, mockValue, 3600, Cache.Visibility.ALL, false); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); System.Assert.isTrue(CacheManager.getSessionCache().contains(mockKey)); System.Assert.areEqual(1, mockSessionPartitionProxy.containsMethodCallCount); @@ -255,7 +255,7 @@ private class CacheManager_Tests { MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); mockOrganizationPartitionProxy.put(mockKey, CacheManager.PLATFORM_CACHE_NULL_VALUE, 3600, Cache.Visibility.ALL, false); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); System.Assert.isTrue(CacheManager.getOrganizationCache().contains(mockKey)); System.Assert.areEqual(1, mockOrganizationPartitionProxy.containsMethodCallCount); @@ -274,7 +274,7 @@ private class CacheManager_Tests { MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); mockSessionPartitionProxy.put(mockKey, CacheManager.PLATFORM_CACHE_NULL_VALUE, 3600, Cache.Visibility.ALL, false); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); System.Assert.isTrue(CacheManager.getSessionCache().contains(mockKey)); System.Assert.areEqual(1, mockSessionPartitionProxy.containsMethodCallCount); @@ -293,7 +293,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(false); System.Assert.isFalse(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getOrganizationCache().contains(mockKey)); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); @@ -314,7 +314,7 @@ private class CacheManager_Tests { System.Type cacheBuilderStubType = CacheBuilderStub.class; MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getOrganizationCache().contains(mockKey)); System.Assert.areEqual(1, mockOrganizationPartitionProxy.containsMethodCallCount); @@ -343,7 +343,7 @@ private class CacheManager_Tests { System.Type cacheBuilderStubType = CacheBuilderStub.class; MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(false); System.Assert.isFalse(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getOrganizationCache().contains(mockKey)); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); @@ -380,7 +380,7 @@ private class CacheManager_Tests { CacheManager.CONFIGURED_CACHE_VALUES.add(configuredCacheValue); MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.isTrue(CacheManager.getOrganizationCache().contains(mockKey)); Object returnedValue = CacheManager.getOrganizationCache().get(mockKey); @@ -405,7 +405,7 @@ private class CacheManager_Tests { CacheManager.CONFIGURED_CACHE_VALUES.add(configuredCacheValue); MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); Object returnedValue = CacheManager.getOrganizationCache().get(mockKey); @@ -421,7 +421,7 @@ private class CacheManager_Tests { User mockValue = null; MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.areEqual(0, mockOrganizationPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getOrganizationCache().contains(mockKey)); System.Assert.areEqual(1, mockOrganizationPartitionProxy.containsMethodCallCount); @@ -442,7 +442,7 @@ private class CacheManager_Tests { User oldMockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.areEqual(0, mockOrganizationPartitionProxy.putMethodCallCount); CacheManager.getOrganizationCache().put(mockKey, oldMockValue); System.Assert.areEqual(1, mockOrganizationPartitionProxy.putMethodCallCount); @@ -467,7 +467,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.isFalse(CacheManager.getOrganizationCache().contains(mockKey)); CacheManager.getOrganizationCache().put(mockKey, mockValue); System.Assert.isTrue(mockOrganizationPartitionProxy.contains(mockKey)); @@ -489,7 +489,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(false); System.Assert.isFalse(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.isFalse(CacheManager.getOrganizationCache().contains(mockKey)); CacheManager.getOrganizationCache().put(mockKey, mockValue); System.Assert.isFalse(mockOrganizationPartitionProxy.contains(mockKey)); @@ -511,7 +511,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.isFalse(CacheManager.getOrganizationCache().contains(mockKey)); CacheManager.getOrganizationCache().put(mockKey, mockValue); System.Assert.isTrue(mockOrganizationPartitionProxy.contains(mockKey)); @@ -534,7 +534,7 @@ private class CacheManager_Tests { static void it_supports_bulk_operations_in_organization_cache() { MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.isTrue(CacheManager.getOrganizationCache().isAvailable()); Map keyToValue = new Map{ 'SomeDate' => Date.newInstance(1999, 9, 9), @@ -565,7 +565,7 @@ private class CacheManager_Tests { static void it_remove_alls_keys_in_organization_cache_when_remove_all_method_is_called() { MockPlatformCachePartitionProxy mockOrganizationPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockOrganizationPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.ORGANIZATION, mockOrganizationPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.ORGANIZATION, mockOrganizationPartitionProxy); System.Assert.isTrue(CacheManager.getOrganizationCache().isAvailable()); Map keyToValue = new Map{ 'SomeDate' => Date.newInstance(1999, 9, 9), @@ -586,7 +586,7 @@ private class CacheManager_Tests { System.Type cacheBuilderStubType = CacheBuilderStub.class; MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getSessionCache().contains(mockKey)); System.Assert.areEqual(1, mockSessionPartitionProxy.containsMethodCallCount); @@ -615,7 +615,7 @@ private class CacheManager_Tests { System.Type cacheBuilderStubType = CacheBuilderStub.class; MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(false); System.Assert.isFalse(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getSessionCache().contains(mockKey)); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); @@ -644,7 +644,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getSessionCache().contains(mockKey)); System.Assert.areEqual(1, mockSessionPartitionProxy.containsMethodCallCount); @@ -665,7 +665,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(false); System.Assert.isFalse(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getSessionCache().contains(mockKey)); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); @@ -694,7 +694,7 @@ private class CacheManager_Tests { CacheManager.CONFIGURED_CACHE_VALUES.add(configuredCacheValue); MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.isTrue(CacheManager.getSessionCache().contains(mockKey)); Object returnedValue = CacheManager.getSessionCache().get(mockKey); @@ -719,7 +719,7 @@ private class CacheManager_Tests { CacheManager.CONFIGURED_CACHE_VALUES.add(configuredCacheValue); MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); Object returnedValue = CacheManager.getSessionCache().get(mockKey); @@ -735,7 +735,7 @@ private class CacheManager_Tests { User mockValue = null; MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.areEqual(0, mockSessionPartitionProxy.containsMethodCallCount); System.Assert.isFalse(CacheManager.getSessionCache().contains(mockKey)); System.Assert.areEqual(1, mockSessionPartitionProxy.containsMethodCallCount); @@ -756,7 +756,7 @@ private class CacheManager_Tests { User oldMockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.areEqual(0, mockSessionPartitionProxy.putMethodCallCount); CacheManager.getSessionCache().put(mockKey, oldMockValue); System.Assert.areEqual(1, mockSessionPartitionProxy.putMethodCallCount); @@ -781,7 +781,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.isFalse(CacheManager.getSessionCache().contains(mockKey)); CacheManager.getSessionCache().put(mockKey, mockValue); System.Assert.isTrue(mockSessionPartitionProxy.contains(mockKey)); @@ -803,7 +803,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(false); System.Assert.isFalse(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.isFalse(CacheManager.getSessionCache().contains(mockKey)); CacheManager.getSessionCache().put(mockKey, mockValue); System.Assert.isFalse(mockSessionPartitionProxy.contains(mockKey)); @@ -825,7 +825,7 @@ private class CacheManager_Tests { User mockValue = new User(Id = System.UserInfo.getUserId(), ProfileId = System.UserInfo.getProfileId()); MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.isFalse(CacheManager.getSessionCache().contains(mockKey)); CacheManager.getSessionCache().put(mockKey, mockValue); System.Assert.isTrue(mockSessionPartitionProxy.contains(mockKey)); @@ -848,7 +848,7 @@ private class CacheManager_Tests { static void it_supports_bulk_operations_in_session_cache() { MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.isTrue(CacheManager.getSessionCache().isAvailable()); Map keyToValue = new Map{ 'SomeDate' => Date.newInstance(1999, 9, 9), @@ -879,7 +879,7 @@ private class CacheManager_Tests { static void it_remove_alls_keys_in_session_cache_when_remove_all_method_is_called() { MockPlatformCachePartitionProxy mockSessionPartitionProxy = new MockPlatformCachePartitionProxy(true); System.Assert.isTrue(mockSessionPartitionProxy.isAvailable()); - CacheManager.setMockPartitionProxy(CacheManager.PlatformCacheType.SESSION, mockSessionPartitionProxy); + CacheManager.setMockPartitionProxy(CacheManager.PlatformCachePartitionType.SESSION, mockSessionPartitionProxy); System.Assert.isTrue(CacheManager.getSessionCache().isAvailable()); Map keyToValue = new Map{ 'SomeDate' => Date.newInstance(1999, 9, 9), @@ -1058,4 +1058,4 @@ private class CacheManager_Tests { return mockValue; } } -} +} \ No newline at end of file diff --git a/nebula-cache-manager/core/classes/CacheManager_Tests.cls-meta.xml b/nebula-cache-manager/core/classes/CacheManager_Tests.cls-meta.xml index 1248daa8..651b1729 100644 --- a/nebula-cache-manager/core/classes/CacheManager_Tests.cls-meta.xml +++ b/nebula-cache-manager/core/classes/CacheManager_Tests.cls-meta.xml @@ -1,5 +1,5 @@ - + - 56.0 + 61.0 Active diff --git a/nebula-cache-manager/core/customMetadata/CacheConfiguration.Organization.md-meta.xml b/nebula-cache-manager/core/customMetadata/CacheConfiguration.Organization.md-meta.xml index 448db17a..d899d526 100644 --- a/nebula-cache-manager/core/customMetadata/CacheConfiguration.Organization.md-meta.xml +++ b/nebula-cache-manager/core/customMetadata/CacheConfiguration.Organization.md-meta.xml @@ -1,9 +1,5 @@ - - + + false diff --git a/nebula-cache-manager/core/customMetadata/CacheConfiguration.Session.md-meta.xml b/nebula-cache-manager/core/customMetadata/CacheConfiguration.Session.md-meta.xml index 762b8b48..97e94d61 100644 --- a/nebula-cache-manager/core/customMetadata/CacheConfiguration.Session.md-meta.xml +++ b/nebula-cache-manager/core/customMetadata/CacheConfiguration.Session.md-meta.xml @@ -1,9 +1,5 @@ - - + + false diff --git a/nebula-cache-manager/core/customMetadata/CacheConfiguration.Transaction.md-meta.xml b/nebula-cache-manager/core/customMetadata/CacheConfiguration.Transaction.md-meta.xml index c0bcf68b..6ef4de54 100644 --- a/nebula-cache-manager/core/customMetadata/CacheConfiguration.Transaction.md-meta.xml +++ b/nebula-cache-manager/core/customMetadata/CacheConfiguration.Transaction.md-meta.xml @@ -1,9 +1,5 @@ - - + + false @@ -16,11 +12,11 @@ PlatformCachePartitionName__c - + PlatformCacheTimeToLive__c - + PlatformCacheVisibility__c diff --git a/nebula-cache-manager/core/layouts/CacheConfiguration__mdt-Cache Configuration Layout.layout-meta.xml b/nebula-cache-manager/core/layouts/CacheConfiguration__mdt-Cache Configuration Layout.layout-meta.xml index 9b4350d3..5228eb20 100644 --- a/nebula-cache-manager/core/layouts/CacheConfiguration__mdt-Cache Configuration Layout.layout-meta.xml +++ b/nebula-cache-manager/core/layouts/CacheConfiguration__mdt-Cache Configuration Layout.layout-meta.xml @@ -1,4 +1,4 @@ - + false @@ -82,9 +82,9 @@ true false - - - + + + diff --git a/nebula-cache-manager/core/layouts/CacheValue__mdt-Cache Value Layout.layout-meta.xml b/nebula-cache-manager/core/layouts/CacheValue__mdt-Cache Value Layout.layout-meta.xml index 0874758a..51310d83 100644 --- a/nebula-cache-manager/core/layouts/CacheValue__mdt-Cache Value Layout.layout-meta.xml +++ b/nebula-cache-manager/core/layouts/CacheValue__mdt-Cache Value Layout.layout-meta.xml @@ -1,4 +1,4 @@ - + false @@ -80,9 +80,9 @@ true false - - - + + + false diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/CacheConfiguration__mdt.object-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/CacheConfiguration__mdt.object-meta.xml index 9d2db744..5a219c75 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/CacheConfiguration__mdt.object-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/CacheConfiguration__mdt.object-meta.xml @@ -1,4 +1,4 @@ - + Used by Nebula Cache Manager to control the runtime behavior of different caches diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/IsEnabled__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/IsEnabled__c.field-meta.xml index 7c3dca29..5d3f28f9 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/IsEnabled__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/IsEnabled__c.field-meta.xml @@ -1,8 +1,7 @@ - + IsEnabled__c true - false SubscriberControlled Checkbox diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/IsImmutable__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/IsImmutable__c.field-meta.xml index 3fd2eb89..7a900003 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/IsImmutable__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/IsImmutable__c.field-meta.xml @@ -1,10 +1,8 @@ - + IsImmutable__c false - Indicates if cache values can be changed once set (IsImmutable__c = false) or if existing values are locked until they expire (IsImmutable__c = true) - false + Indicates if cache values can be changed once set (IsImmutable__c = false) or if existing values are locked until they expire (IsImmutable__c = true) DeveloperControlled Checkbox diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCachePartitionName__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCachePartitionName__c.field-meta.xml index b87cf226..a4730dd6 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCachePartitionName__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCachePartitionName__c.field-meta.xml @@ -1,4 +1,4 @@ - + PlatformCachePartitionName__c false diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheTimeToLive__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheTimeToLive__c.field-meta.xml index a98d7f2b..201e354f 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheTimeToLive__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheTimeToLive__c.field-meta.xml @@ -1,4 +1,4 @@ - + PlatformCacheTimeToLive__c false diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheVisibility__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheVisibility__c.field-meta.xml index 01407254..c03227b2 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheVisibility__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheVisibility__c.field-meta.xml @@ -1,7 +1,6 @@ - + PlatformCacheVisibility__c - false DeveloperControlled false diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/listViews/All.listView-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/listViews/All.listView-meta.xml index 9360959d..60f4e9bf 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/listViews/All.listView-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/listViews/All.listView-meta.xml @@ -1,4 +1,4 @@ - + All MasterLabel diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/CacheValue__mdt.object-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/CacheValue__mdt.object-meta.xml index f7503539..32eb86ac 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/CacheValue__mdt.object-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/CacheValue__mdt.object-meta.xml @@ -1,4 +1,4 @@ - + Used by Nebula Cache Manager to automatically load configured cache values into the specified cache at runtime diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Cache__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Cache__c.field-meta.xml index b9401d23..9fd6bd00 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Cache__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Cache__c.field-meta.xml @@ -1,7 +1,6 @@ - + Cache__c - false DeveloperControlled CacheConfiguration__mdt diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/DataType__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/DataType__c.field-meta.xml index e243a7d2..f857204e 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/DataType__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/DataType__c.field-meta.xml @@ -1,10 +1,9 @@ - + DataType__c false DeveloperControlled - The Apex type of the provided value. This can be any valid Apex type that supports JSON deserialization, such as a primitive data type like String, Boolean, Datetime, or a custom Apex class + The Apex type of the provided value. This can be any valid Apex type that supports JSON deserialization, such as a primitive data type like String, Boolean, Datetime, or a custom Apex class 255 true diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/IsEnabled__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/IsEnabled__c.field-meta.xml index 229d931e..6e5658ae 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/IsEnabled__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/IsEnabled__c.field-meta.xml @@ -1,8 +1,7 @@ - + IsEnabled__c true - false DeveloperControlled Checkbox diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Key__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Key__c.field-meta.xml index 70723de0..fbe20f55 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Key__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Key__c.field-meta.xml @@ -1,4 +1,4 @@ - + Key__c false diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Value__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Value__c.field-meta.xml index 47198d70..1d38c104 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Value__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Value__c.field-meta.xml @@ -1,7 +1,6 @@ - + Value__c - false DeveloperControlled 131072 diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/listViews/All.listView-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/listViews/All.listView-meta.xml index 9b1ef536..ed1fc9da 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/listViews/All.listView-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/listViews/All.listView-meta.xml @@ -1,4 +1,4 @@ - + All MasterLabel diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/validationRules/KeyMustBeAlphanumeric.validationRule-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/validationRules/KeyMustBeAlphanumeric.validationRule-meta.xml index faeaa99c..334baf79 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/validationRules/KeyMustBeAlphanumeric.validationRule-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/validationRules/KeyMustBeAlphanumeric.validationRule-meta.xml @@ -1,4 +1,4 @@ - + KeyMustBeAlphanumeric true diff --git a/nebula-cache-manager/core/permissionsets/CacheManagerAdmin.permissionset-meta.xml b/nebula-cache-manager/core/permissionsets/CacheManagerAdmin.permissionset-meta.xml index 827f8793..18ad8a0e 100644 --- a/nebula-cache-manager/core/permissionsets/CacheManagerAdmin.permissionset-meta.xml +++ b/nebula-cache-manager/core/permissionsets/CacheManagerAdmin.permissionset-meta.xml @@ -1,4 +1,4 @@ - + CacheManager diff --git a/nebula-cache-manager/recipes/classes/RecordSelector.cls-meta.xml b/nebula-cache-manager/recipes/classes/RecordSelector.cls-meta.xml index 1248daa8..651b1729 100644 --- a/nebula-cache-manager/recipes/classes/RecordSelector.cls-meta.xml +++ b/nebula-cache-manager/recipes/classes/RecordSelector.cls-meta.xml @@ -1,5 +1,5 @@ - + - 56.0 + 61.0 Active diff --git a/package.json b/package.json index 83a4572d..e5a6ae11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nebula-cache-manager", - "version": "1.0.2", + "version": "1.0.3", "description": "A flexible cache management system for Salesforce Apex developers. Built to be scalable & configurable.", "scripts": { "lint": "eslint **/{aura,lwc}/**", diff --git a/sfdx-project.json b/sfdx-project.json index d4989a4e..913ad80c 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -2,14 +2,14 @@ "name": "Nebula Cache Manager", "namespace": "", "sfdcLoginUrl": "https://login.salesforce.com", - "sourceApiVersion": "56.0", + "sourceApiVersion": "61.0", "pushPackageDirectoriesSequentially": true, "packageDirectories": [ { "package": "Nebula Cache Manager (no namespace)", "path": "./nebula-cache-manager/core/", "definitionFile": "./config/scratch-orgs/base-scratch-def.json", - "versionNumber": "1.0.2.0", + "versionNumber": "1.0.3.0", "versionName": "Updated CacheManager methods from public to global", "versionDescription": "All relevant methods in CacheManager (and its inner classses) have been changed to global so that they're accessible in the namespaced package", "releaseNotesUrl": "https://github.com/jongpie/NebulaCacheManager/releases", @@ -19,7 +19,7 @@ "package": "Nebula Cache Manager (Nebula namespace)", "path": "./nebula-cache-manager/core/", "definitionFile": "./config/scratch-orgs/base-scratch-def.json", - "versionNumber": "1.0.2.0", + "versionNumber": "1.0.3.0", "versionName": "Updated CacheManager methods from public to global", "versionDescription": "All relevant methods in CacheManager (and its inner classses) have been changed to global so that they're accessible in the namespaced package", "releaseNotesUrl": "https://github.com/jongpie/NebulaCacheManager/releases", From 617a9626e10388437135e89b4a4e68e8d2acb5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wo=C5=BAniak?= Date: Thu, 12 Sep 2024 17:12:58 +0200 Subject: [PATCH 2/2] Add more help text and descriptions based on lecture of Salesforce documentation Improved README.md by description of required and optional setup and mentioning diagnostics option. --- README.md | 15 +++++++++++++-- .../CacheManagerPartition.cachePartition-meta.xml | 3 ++- .../PlatformCacheTimeToLive__c.field-meta.xml | 3 +++ .../PlatformCacheVisibility__c.field-meta.xml | 3 +++ .../CacheValue__mdt/fields/Key__c.field-meta.xml | 1 + .../fields/Value__c.field-meta.xml | 4 +++- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3017f35a..30ed6033 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,28 @@ A flexible cache management system for Salesforce Apex developers. Built to be s 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 +## Unlocked Package - `Nebula` Namespace - v1.0.3 [![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 +## Unlocked Package - No Namespace - v1.0.3 [![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) --- +## Required setup after installation +Go to Setup -> Custom Code -> Platform Cache. Click on `CacheManagerPartition` then click Edit button set at least 1 MB for "Session Cache Allocation" and 1 MB "Org Cache Allocation". +This is needed as otherwise cache won't work with default 0 values. + +If you want to debug and see what is stored in cache go to your user profile and check "Cache Diagnostics" checkbox, then save. +Now if you go again to Platform Cache and click `CacheManagerPartition` you will see additional field with link arrow named "Diagnostics". When clicked it opens teh page with all details and statistics about cache. + +## Optional setup +In Custom metadata you will see `Cache Configuration` and `Cache Value` metadata types. +In `Cache Configuration` you can adjust if cache type is enabled or disabled, set it as immutable, set cache time to live value and define if it is global or namespace scoped cache. +In `Cache Value` you can define persistent values which should be always available in cache. ## Cache Manager for Apex: Quick Start diff --git a/nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml b/nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml index c4ef8704..7beb9c49 100644 --- a/nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml +++ b/nebula-cache-manager/core/cachePartitions/CacheManagerPartition.cachePartition-meta.xml @@ -1,6 +1,7 @@ - Platform cache partition used by Nebula Cache Manager + Platform cache partition used by Nebula Cache Manager. +When a partition has no allocation, cache operations (such as get and put) are not invoked, and no error is returned. Set minimum 1 MB for each type. false CacheManagerPartition diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheTimeToLive__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheTimeToLive__c.field-meta.xml index 201e354f..2e3fc761 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheTimeToLive__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheTimeToLive__c.field-meta.xml @@ -1,8 +1,11 @@ PlatformCacheTimeToLive__c + Documentation https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_platform_cache_limits.htm false DeveloperControlled + 300 seconds (5 minutes) to 28800 seconds (8 hours) for Session cache. +300 seconds (5 minutes) to 172800 seconds (48 hours) for Organization cache, default 86400 seconds (24 hours). 18 false diff --git a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheVisibility__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheVisibility__c.field-meta.xml index c03227b2..ece2fa3d 100644 --- a/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheVisibility__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheConfiguration__mdt/fields/PlatformCacheVisibility__c.field-meta.xml @@ -1,7 +1,10 @@ PlatformCacheVisibility__c + Documentation https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_cache_Visibility.htm DeveloperControlled + When "Namespace" is set then cached data in one namespace isn't overwritten and accessible by similar key in another namespace. +If a key has the Visibility.NAMESPACE attribute, a get method initiated from a different namespace returns null. false Picklist diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Key__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Key__c.field-meta.xml index fbe20f55..00bdd43d 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Key__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Key__c.field-meta.xml @@ -3,6 +3,7 @@ Key__c false DeveloperControlled + Key must be alphanumeric. Only a-z, A-Z and 0-9 characters are allowed. 255 true diff --git a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Value__c.field-meta.xml b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Value__c.field-meta.xml index 1d38c104..2091dd2c 100644 --- a/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Value__c.field-meta.xml +++ b/nebula-cache-manager/core/objects/CacheValue__mdt/fields/Value__c.field-meta.xml @@ -1,9 +1,11 @@ Value__c + Documentation https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_platform_cache_limits.htm DeveloperControlled + Maximum size of a single cached item is 100 KB which is 102400 characters. - 131072 + 102400 LongTextArea 5