Implement a simple caching system using static variables. Create methods to manage cache operations: cacheGet() to retrieve/store values, cacheContainsKey() to check cache contents, and clearCache() to reset the cache. The expensive operation is simulated by converting the key to uppercase and appending '-processed'.
Examples
Input: Cache.get('user1')
Output: 'USER1-processed'
Explanation: Key not in cache, performs expensive operation and stores result.
Input: Cache.get('user1') (called again)
Output: 'USER1-processed'
Explanation: Key found in cache, returns cached value without recalculation.
Input: Cache.get('data')
Output: 'DATA-processed'
Explanation: Different key, performs expensive operation and stores result.
Apex Code Editor
Welcome to Lightning Challenge!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Note
You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.