T GetCachedMeta( string keyName, T defaultValue )
T GetCachedMeta( string keyName, System.Func<T> defaultValue )

robot_2Generated
code_blocksInput

Description

The GetCachedMeta method retrieves a cached metadata value associated with a specified key from a package. If the key does not exist in the cache, it returns a default value provided by the caller. This method is useful for accessing metadata that has been previously stored and cached, allowing for quick retrieval without the need for recalculating or fetching from a remote source.

Usage

To use the GetCachedMeta method, you need to provide the key name as a string and a default value of type T. The method will return the cached value if it exists; otherwise, it will return the default value.

Example usage:

var package = new Package();
string key = "author";
string defaultAuthor = "Unknown";
string author = package.GetCachedMeta(key, defaultAuthor);

In this example, the method attempts to retrieve the cached metadata for the key "author". If the key is not found, it returns "Unknown" as the default value.

Example

var package = new Package();
string key = "author";
string defaultAuthor = "Unknown";
string author = package.GetCachedMeta(key, defaultAuthor);
// Use the 'author' variable as needed