コード例 #1
0
 function test1()
 {
     $brain = new Brain();
     $this->assertEquals('mr cool', $brain->load('name'));
 }
コード例 #2
0
ファイル: ex1.php プロジェクト: martinlindhe/php-traits
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use MartinLindhe\Traits\DiskCacheTrait;
class Brain
{
    use DiskCacheTrait;
    public function __construct()
    {
        $this->cacheTtlSeconds(1);
        $this->store('name', 'mr cool');
    }
}
$brain = new Brain();
$res = $brain->load('name');
nfo("got " . $res);
sleep(2);
$res = $brain->load('name');
nfo("got " . $res);