mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Fixed bug that the value of ttl will be converted to 0 when you don't set it. (#3301)
Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
parent
4bdf88524f
commit
18b40615f5
@ -1,5 +1,9 @@
|
||||
# v2.1.8 - TBD
|
||||
|
||||
## Fixed
|
||||
|
||||
- [#3301](https://github.com/hyperf/hyperf/pull/3301) Fixed bug that the value of ttl will be converted to 0 when you don't set it for `hyperf/cache`.
|
||||
|
||||
# v2.1.7 - 2021-02-22
|
||||
|
||||
## Fixed
|
||||
|
6
src/cache/src/Annotation/CachePut.php
vendored
6
src/cache/src/Annotation/CachePut.php
vendored
@ -30,7 +30,7 @@ class CachePut extends AbstractAnnotation
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var null|int
|
||||
*/
|
||||
public $ttl;
|
||||
|
||||
@ -48,7 +48,9 @@ class CachePut extends AbstractAnnotation
|
||||
public function __construct($value = null)
|
||||
{
|
||||
parent::__construct($value);
|
||||
$this->ttl = (int) $this->ttl;
|
||||
if ($this->ttl !== null) {
|
||||
$this->ttl = (int) $this->ttl;
|
||||
}
|
||||
$this->offset = (int) $this->offset;
|
||||
}
|
||||
}
|
||||
|
6
src/cache/src/Annotation/Cacheable.php
vendored
6
src/cache/src/Annotation/Cacheable.php
vendored
@ -32,7 +32,7 @@ class Cacheable extends AbstractAnnotation
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var null|int
|
||||
*/
|
||||
public $ttl;
|
||||
|
||||
@ -60,7 +60,9 @@ class Cacheable extends AbstractAnnotation
|
||||
public function __construct($value = null)
|
||||
{
|
||||
parent::__construct($value);
|
||||
$this->ttl = (int) $this->ttl;
|
||||
if ($this->ttl !== null) {
|
||||
$this->ttl = (int) $this->ttl;
|
||||
}
|
||||
$this->offset = (int) $this->offset;
|
||||
}
|
||||
|
||||
|
16
src/cache/tests/Cases/AnnotationTest.php
vendored
16
src/cache/tests/Cases/AnnotationTest.php
vendored
@ -52,6 +52,22 @@ class AnnotationTest extends TestCase
|
||||
$this->assertSame('test', $annotation->prefix);
|
||||
$this->assertSame(3600, $annotation->ttl);
|
||||
$this->assertSame(100, $annotation->offset);
|
||||
|
||||
$annotation = new Cacheable([
|
||||
'prefix' => 'test',
|
||||
'ttl' => null,
|
||||
]);
|
||||
|
||||
$this->assertSame('test', $annotation->prefix);
|
||||
$this->assertSame(null, $annotation->ttl);
|
||||
|
||||
$annotation = new CachePut([
|
||||
'prefix' => 'test',
|
||||
'ttl' => null,
|
||||
]);
|
||||
|
||||
$this->assertSame('test', $annotation->prefix);
|
||||
$this->assertSame(null, $annotation->ttl);
|
||||
}
|
||||
|
||||
public function testAnnotationManager()
|
||||
|
Loading…
Reference in New Issue
Block a user