prowebcraft/yii2-lazy-cache

Lazy cache functions

dev-main 2022-05-23 13:06 UTC

This package is auto-updated.

Last update: 2024-10-23 18:09:57 UTC


README

Lazy cache functions

Usage

Attach Lazy trait to your class

<?php

class HeavyJob {
    
    use \prowebcraft\yii2lazycache\Lazy;

}

Wrap heavy data in lazy function

$rocketToMarsTrajectory = $this->lazyWithCache('mars.trajectory', function() {
    // this function will be called once a day
    $trajectory = null;
    // heavy calculation here
    return $trajectory;
});