PHP code example of heropoo / cache
1. Go to this page and download the library: Download heropoo/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/ */
heropoo / cache example snippets
t = 'localhost';
$port = 6379;
$password = null;
$database = 0;
$redis = new \Moon\Cache\Redis($host, $port, $password, $database);
$user_id = 1;
$user = $redis->cache('test', 10, function () use ($user_id) {
// some db query or other code ...
$user = [
'id' => $user_id,
'username' => 'xiaoming',
'sex' => 1,
'crated_at' => time()
];
return $user;
});
var_dump($user);