Module: Platform Cache Basics -Salesforce answers

In this article, we will see the solution of Module: Platform Cache Basics -Salesforce Answers

#1.Get Started with Platform Cache

Q1)Which one of these is a characteristic of data that’s appropriate to cache?

I)Reused throughout a session
II)Reused across all users and requests
III)Rapidly changing
IV)Cheap to compute or retrieve
V)A and B

V)A and B

Q2)Platform Cache supports:

I)Persistent storage
II)Session data
III)Org data
IV)A, B, and C
V)B and C

V)B and C

Q3)What type of data is suitable to store in the session cache?

I)Data that is shared among all users in the org
II)Data that is specific to a particular user and is tied to that user’s session
III)Data that is tied to one partition
IV)Statistics about a Salesforce session

II)Data that is specific to a particular user and is tied to that user’s session

Q4)Which is a valid capacity allocation for org and session cache in a partition?

I)Org cache 1, Session cache 1
II)Org cache 5, Session cache 0
III)Org cache 5.5, Session cache 5.5
IV)A and C
V)None of the above

II)Org cache 5, Session cache 0

#2.Use Org & Session Cache

Hands-on Challenge
Earn+500 points

Create an Apex class that writes and reads from the org cache.
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.I) The first method, putSchedule(), returns void and takes these parameters: String busLine, Time[] schedule.II) 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.
My Trailhead Playground 1
Last used on 11/26/2021
Complete the Challenge to Earn 500Points

#3.Walk Through a Sample Application and Discover Cache Diagnostics

Q1)An API call to fetch data takes the most time, SOQL queries are faster, and fetching data from the cache is the fastest way to get data. When should you use the API or SOQL queries compared to the cache?

I)Make API calls to refresh external data when necessary. Optionally, store data in Salesforce temporarily as a way to resupply the cache without having to make API calls often. Get the data from the cache whenever possible.
II)Make API calls on a regular basis to refresh your data. Either store and retrieve the data through SOQL or the cache.
III)When not using external data from API web services, retrieve data from Salesforce through SOQL queries to refresh your data when necessary and store data in the cache for fast retrieval.
IV)To save time, only get the data from the cache (provided the chipmunk hasn’t eaten it).
V)A and C

V)A and C

Q2)Your app displays data using a list of custom object records. The purpose is to reduce app processing time. Assume your app is below cache storage limits. How should the cache values be stored?

I)Store the data as sObjects in the cache with multiple keys.
II)Store the data as fields, then convert them to sObjects before displaying them.
III)Store the data as a list of sObjects with one key.
IV)Store the data as instances of your own custom class.

III)Store the data as a list of sObjects with one key.

Q3)Your app displays bus schedules for a transportation agency. Storing all the schedules in the cache would exceed cache limits. You know that only a handful of bus schedules are requested most. Which of the following options are best to store schedules in the cache?

I)A list of randomly selected schedules
II)Assuming that the list of most requested schedules is provided and doesn’t change, store the most requested schedules and a key for each bus schedule.
III)All schedules stored in separate keys. The key used least recently might get evicted from the cache.
IV)B and C

IV)B and C

Spread the love

Leave a Reply

%d bloggers like this: