1. Go to this page and download the library: Download zalatov/runtime-cache-trait library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zalatov / runtime-cache-trait example snippets
class Product {
private $images;
public function getImages(): array {
if (null === $this->images) {
$this->images = [new Image];
}
return $this->images;
}
}
class Product {
use RuntimeCacheTrait;
public function getImages(): array {
return $this->objectRuntimeCache(__METHOD__, function() {
return [new Image];
});
}
}
class Product extends \yii\db\ActiveRecord {
use RuntimeCacheTrait;
public static function getModel(string $id): ?self {
return static::globalRuntimeCache([__METHOD__, $id], function() use ($id) {
return static::findOne($Id);
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.