Plugin development: initialization based on config

How would one define a function that produce some values (which will be used each time a request comes) based only on the plugin configuration?
Running the function each time a request comes is not efficient since the the values generated only depends on the plugin configuration and the computation is quite heavy.
If the solution is to use cache to store the values, then how to handle the invalidation, especially when the plugin is deleted or the configuration is updated?

Hi,

A good example of this can be found in the bot-detection plugin:

This table will maintain a cache per plugin configuration.

Thanks, thats a great referrence. Will try it soon