heropoo / cache
cache component
v0.3
2020-03-31 03:44 UTC
Requires
- php: >= 5.4
- predis/predis: ^1.1
This package is auto-updated.
Last update: 2024-11-29 06:01:03 UTC
README
A cache component.
Supported
- redis
TODO
- support redis cluster
- support other cache media
usage
<?php require_once __DIR__.'/vendor/autoload.php'; $host = '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);