Create an Apex class that writes and reads from the org cache | Salesforce Trailhead Solution HD

02.10.2018
Buy Me a Coffee? https://www.paypal.me/jiejenn/5 Your donation will help me to continue to make more tutorial videos! Trailhead Challenge Link https://trailhead.salesforce.com/en/content/learn/modules/platform_cache/platform_cache_use In this challenge, you’ll write an Apex class that writes and reads a bus schedule from the org cache. Your method for reading the cache has to handle cache misses. Create a partition called BusSchedule with 0 MB for the size of org cache and session cache. The 0 MB allocation enables you to test cache misses. Create a public Apex class called BusScheduleCache. Add this variable to the class: private Cache.OrgPartition part; In the constructor, create a new instance of Cache.OrgPartition by passing it the partition name (local.BusSchedule). Assign this object to the class variable (part). Add two public methods. a. The first method, putSchedule(), returns void and takes these parameters: String busLine, Time[] schedule. b. The second method, getSchedule(), returns a bus schedule as a time array (Time[]) and takes this parameter: String busLine. Implement the putSchedule() method so that it stores the passed-in values in the org cache by using the partition class variable (part). Implement the getSchedule() method so that it returns the schedule for the specified bus line by using the partition class variable (part). Add logic to the getSchedule() method to handle cache misses. If null is returned for the cached value, getSchedule() should return the following default schedule as a Time array with two Time objects: one Time object value of 8am and another of 5pm. Use the Apex Time.newInstance() method to create the Time objects. For more Salesforce Trailhead Solution videos, please visit https://learndataanalysis.org/salesforce-trailhead-solution/ Visit my website https://LearnDataAnalysis.org

Похожие видео

Показать еще