AD0-E725 practice question 4 of 10

An Adobe Commerce Developer is tasked to frequently send data to a third-party API. The API utilizes a JSON Web Token (JWT) that expires every hour. The developer decides to store the JWT in a custom cache. Which step should the Developer take to implement this new custom cache type correctly?

Full set: 50 questions
Answer options
A: Define the custom cache type in the di.xml, ensuring the cache model implements CacheInterface.
B: Define the custom cache type in cache.xml with a unique name and instance. Correct answer
C: Define the custom cache type directly in system.xml at the website level.
Correct Answer:
B. Define the custom cache type in cache.xml with a unique name and instance.
Explanation

In Adobe Commerce, the etc/cache.xml file is the designated configuration file for declaring new cache types. To integrate a custom cache into the system so it can be managed via the command line (bin/magento cache:) and the admin panel, a developer must define it in this file. The definition requires a unique id (name) and an instance attribute specifying the model class that handles the cache logic. This makes the cache type known to the Magento application's cache management system.

Why Incorrect

A. di.xml is used for dependency injection configuration, not for declaring new cache types that are integrated into the core cache management system.
C. system.xml is used to create configuration fields in the Magento Admin panel under Stores > Settings > Configuration, not for defining core functionalities like cache types.

References

1. Adobe Commerce Developer Guide. (n.d.). Add a cache type. Adobe Experience League. Retrieved from https://developer.adobe.com/commerce/php/development/cache/custom/

Section: "Declare the cache type" - This section explicitly states: "To declare the cache type

create a cache.xml file in the /etc directory." It provides a clear example of the XML structure

including the type node with name and instance attributes.

Scroll to Top