octane cache中的interval如何使用呢
1. 运行环境
1). 当前使用的 Laravel 版本?
9
2). 当前使用的 php/php-fpm 版本?
PHP 版本:8.1
2. 问题描述?
Cache::store('octane')->interval('random', function () {
return Str::random(10);
}, seconds: 5);
echo(Cache::store('octane')->get('random'));
//在间隔期内每次获取到的结果都是重新生成的随机字符串
//查看源码
public function get($key)
{
$record = $this->table->get($key);
if (! $this->recordIsFalseOrExpired($record)) {
return unserialize($record['value']);
}
if (in_array($key, $this->intervals) &&
! is_null($interval = $this->getInterval($key))) {
return $interval['resolver']();
}
}
似乎每次返回的都是function(){}()本身
3. 您期望得到的结果?
间隔期内返回相同数据
推荐文章: