From 3bc7feb0f983e042aa7b26bc6dbbfca74db4c0fe Mon Sep 17 00:00:00 2001 From: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> Date: Wed, 18 Feb 2026 05:04:28 -0500 Subject: [PATCH] Add note about get_cache_key in the inventory plugin dev guide (#3468) * Add notes about cache limitations in the inventory plugin development guide * Update docs/docsite/rst/dev_guide/developing_inventory.rst Co-authored-by: Abhijeet Kasurde * Update docs/docsite/rst/dev_guide/developing_inventory.rst * Update docs/docsite/rst/dev_guide/developing_inventory.rst Co-authored-by: Don Naro * Add recommendation to avoid multiple cache entries --------- Co-authored-by: Abhijeet Kasurde Co-authored-by: Don Naro --- docs/docsite/rst/dev_guide/developing_inventory.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docsite/rst/dev_guide/developing_inventory.rst b/docs/docsite/rst/dev_guide/developing_inventory.rst index dfef1c3b26..8e1daf6bbb 100644 --- a/docs/docsite/rst/dev_guide/developing_inventory.rst +++ b/docs/docsite/rst/dev_guide/developing_inventory.rst @@ -248,6 +248,8 @@ Before using the cache plugin, you must retrieve a unique cache key by using the self.load_cache_plugin() cache_key = self.get_cache_key(path) +.. note:: The ``get_cache_key`` is a helper method that retrieves a unique key for the plugin name and the ``path`` parameter. Inventory plugins that generate multiple unique cache entries should not use this helper method because it is designed to get one key per inventory source. In general we recommend that plugin developers refactor to avoid multiple cache entries for inventory sources. + Now that you've enabled caching, loaded the correct plugin, and retrieved a unique cache key, you can set up the flow of data between the cache and your inventory using the ``cache`` parameter of the ``parse`` method. This value comes from the inventory manager and indicates whether the inventory is being refreshed (such as by the ``--flush-cache`` or the meta task ``refresh_inventory``). Although the cache shouldn't be used to populate the inventory when being refreshed, the cache should be updated with the new inventory if the user has enabled caching. You can use ``self._cache`` like a dictionary. The following pattern allows refreshing the inventory to work in conjunction with caching. .. code-block:: python