vendor/codeages/biz-framework/src/Dao/RedisCache.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Codeages\Biz\Framework\Dao;

use Symfony\Component\EventDispatcher\EventDispatcher;

class RedisCache
{
    /**
     * @var \Redis|\RedisArray
     */
    protected $redis;

    /**
     * @var EventDispatcher
     */
    protected $eventDispatcher;

    public function __construct($redis, EventDispatcher $eventDispatcher)
    {
        $this->redis = $redis;
        $this->eventDispatcher = $eventDispatcher;
    }

    public function get($key)
    {
        return $this->redis->get($key);
    }

    public function set($key, $value, $lifetime = 0)
    {
        $this->redis->set($key, $value, $lifetime);
        $this->eventDispatcher->dispatch('dao.cache.set', new CacheEvent($key, $value, $lifetime));
    }

    public function incr($key)
    {
        $newValue = $this->redis->incr($key);
        $this->eventDispatcher->dispatch('dao.cache.set', new CacheEvent($key, $newValue));
    }

    public function del($key)
    {
        $this->redis->del($key);
        $this->eventDispatcher->dispatch('dao.cache.del', new CacheEvent($key));
    }

    public function __call($name, $arguments)
    {
        return call_user_func_array(array($this->redis, $name), $arguments);
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。