mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-30 02:37:58 +08:00
Update doc.
This commit is contained in:
parent
795bd26542
commit
e7c2781a3f
@ -5,6 +5,7 @@
|
||||
- [#203](https://github.com/hyperf-cloud/hyperf/pull/203) [#236](https://github.com/hyperf-cloud/hyperf/pull/236) [#247](https://github.com/hyperf-cloud/hyperf/pull/247) [#252](https://github.com/hyperf-cloud/hyperf/pull/252) Added View component, support for Blade engine and Smarty engine.
|
||||
- [#203](https://github.com/hyperf-cloud/hyperf/pull/203) Added support for Swoole Task mechanism.
|
||||
- [#245](https://github.com/hyperf-cloud/hyperf/pull/245) Added TaskWorkerStrategy and WorkerStrategy crontab strategies.
|
||||
- [#251](https://github.com/hyperf-cloud/hyperf/pull/251) Added coroutine memory driver for cache.
|
||||
- [#254](https://github.com/hyperf-cloud/hyperf/pull/254) Added support for array value of `RequestMapping::$methods`, `@RequestMapping(methods={"GET"})` and `@RequestMapping(methods={RequestMapping::GET})` are available now.
|
||||
- [#255](https://github.com/hyperf-cloud/hyperf/pull/255) Transfer `Hyperf\Utils\Contracts\Arrayable` result of Request to Response automatically, and added `text/plain` content-type header for string Response.
|
||||
- [#256](https://github.com/hyperf-cloud/hyperf/pull/256) If `Hyperf\Contract\IdGeneratorInterface` exist, the `json-rpc` client will generate a Request ID via IdGenerator automatically, and stored in Request attibute. Also added support for service register and health checks of `jsonrpc` TCP protocol.
|
||||
|
@ -184,3 +184,51 @@ public function updateUserBook(int $id)
|
||||
}
|
||||
```
|
||||
|
||||
## 缓存驱动
|
||||
|
||||
### Redis驱动
|
||||
|
||||
`Hyperf\Cache\Driver\RedisDriver` 会把缓存数据存放到 `Redis` 中,需要用户配置相应的 `Redis配置`。此方式为默认方式。
|
||||
|
||||
### 协程内存驱动
|
||||
|
||||
> 本驱动乃Beta版本,请谨慎使用。
|
||||
|
||||
如果您需要将数据缓存到 `Context` 中,可以尝试次驱动。例如以下应用场景:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Cache\Annotation\Cacheable;
|
||||
|
||||
class Demo {
|
||||
|
||||
public function get($userId, $id)
|
||||
{
|
||||
return $this->getArray($userId)[$id] ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Cacheable(prefix="test", group="co")
|
||||
* @param int $userId
|
||||
* @return array
|
||||
*/
|
||||
public function getArray($userId)
|
||||
{
|
||||
return $this->redis->hGetAll($userId);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
对应配置如下:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
return [
|
||||
'co' => [
|
||||
'driver' => Hyperf\Cache\Driver\CoroutineMemoryDriver::class,
|
||||
'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class,
|
||||
],
|
||||
];
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user