通知短信+运营短信,5秒速达,支持群发助手一键发送🚀高效触达和通知客户 广告
## Doctrine Cache [Doctrine Cache](https://packagist.org/packages/doctrine/cache) 是一个非常流行的缓存库,支持很多种驱动,该库可以在 Mix 中使用,并且可以利用到 [Mix Redis](https://github.com/mix-php/redis) 的连接池。 ## 如何接入 Doctrine Cache 的原生使用方法: ~~~ $redis = new \Redis(); $cache = new \Doctrine\Common\Cache\RedisCache($redis); ~~~ 由于框架中 Mix Redis 是内置连接池,无法直接使用,但是我们保留了获取 \Redis 对象的能力,但是由于池取出的连接析构就会回收 \Redis 对象,因此需要避免连接析构。 ~~~ /** @var \Mix\Redis\Redis $redis */ $redis = context()->get('redis'); $conn = $redis->borrow(); // 注意这里必须单独定义,不然连接会立即析构,会把 \Redis 对象还给池,造成连接调用冲突 $cache = new \Doctrine\Common\Cache\RedisCache($conn->driver->instance()); ~~~