Skip to content
Arjen van Bochoven edited this page May 10, 2020 · 5 revisions

Sometimes your module needs to cache some external data source. To help you do that, MunkiReport version v5.5 and up contains a Cache service. It is a simple key value store and you need to supply the name of your module to prevent different modules overwriting each other's data.

Usage

To store the data, add this code:

munkireport\models\Cache::updateOrCreate(
    [
        'module' => 'the_name_of_your_module', 
        'property' => 'name_of_key',
    ],
    [
        'value' => $some_data,
        'timestamp' => time(),
    ]
);

To retrieve the data

$some_data = munkireport\models\Cache::select('value')
                ->where('module', 'the_name_of_your_module')
                ->where('property', 'name_of_key')
                ->value('value');
Clone this wiki locally