Class BitwardenCacheManager
This class is the single source of truth for the list of credentials from Bitwarden. It handles asynchronous refreshing, persistence to disk for resilience, and provides safe, non-blocking access for the Jenkins UI and other components.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BitwardenCacheManager
Provides global access to the single instance of this manager.Provides a safe, non-blocking way to get the current list of credential metadata.void
Completely removes the credential list from the in-memory cache.void
Schedules a background task to update the Bitwarden item cache after Jenkins starts.void
Triggers a non-destructive, asynchronous refresh of the cache.
-
Constructor Details
-
BitwardenCacheManager
public BitwardenCacheManager()
-
-
Method Details
-
getInstance
Provides global access to the single instance of this manager.- Returns:
- The singleton instance of
BitwardenCacheManager
.
-
updateCache
public void updateCache()Triggers a non-destructive, asynchronous refresh of the cache. This is the standard method for forcing an update from Bitwarden. -
invalidateCache
public void invalidateCache()Completely removes the credential list from the in-memory cache. The next request for credentials will trigger a full, but non-blocking reload.Credential requests that occur during a full reload will receive an empty list of credentials, until the cache has finished repopulating.
-
triggerStartupCacheUpdate
Schedules a background task to update the Bitwarden item cache after Jenkins starts.This method is automatically invoked by Jenkins's startup sequence. It only proceeds if the plugin has been configured. The update is submitted to a background thread to ensure this operation does not block or delay the main Jenkins startup process.
-
getMetadata
Provides a safe, non-blocking way to get the current list of credential metadata.This method returns the current cached data immediately (or an empty list if not yet populated) and triggers a background refresh if the data is stale or missing.
- Returns:
- The current list of
BitwardenItemMetadata
, which may be empty.
-