Commit b4946025 authored by 王源's avatar 王源
Browse files

添加缓存工具类

parent 2e963430
Loading
Loading
Loading
Loading

src/Tools/Cacher.php

0 → 100644
+43 −0
Original line number Diff line number Diff line
<?php

namespace Meibuyu\Micro\Tools;

use Psr\SimpleCache\CacheInterface;

/**
 * Class Cache
 * @package Meibuyu\Micro\Tools
 * @method static get($key, $default = null)
 * @method static set($key, $value, $ttl = null)
 * @method static delete($key)
 * @method static clear()
 * @method static getMultiple($keys, $default = null)
 * @method static setMultiple($values, $ttl = null)
 * @method static deleteMultiple($keys)
 * @method static has($key)
 */
class Cacher
{

    /**
     * @var CacheInterface
     */
    protected static $driver;

    /**
     * @return CacheInterface
     */
    public static function driver()
    {
        if (!self::$driver) {
            self::$driver = container(CacheInterface::class);
        }
        return self::$driver;
    }

    public static function __callStatic($name, $arguments)
    {
        return static::driver()->{$name}(...$arguments);
    }

}
 No newline at end of file