PHP code example of yeszao / cache
1. Go to this page and download the library: Download yeszao/cache 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/ */
yeszao / cache example snippets
namespace app\models;
use yeszao\cache;
class Base
{
public function __call($name, $arguments)
{
$redis = new \Redis();
$redis->connect('redis');
// ***主要是这一行***
return (new Cache($redis))->get($this, $name, $arguments);
}
}
namespace app\models;
use app\models\Base;
class Book extends Base
{
public function getById($id)
{
return ['id' => 100, 'title' => 'PHP documents']
}
}