Skip to content

[BUG] CacheEvict注解带有value属性时无法清除缓存 #7681

Closed

Description

@yxsr-zxx

#[CacheEvict(prefix: "admin",value: "_#{id}")]
这种写法放在方法上面,请求方法时缓存并没有被清除
#[CacheEvict(prefix: "admin")]
去除掉value属性后缓存成功清除

php版本:8.1.32
hyperf版本:3.0
swoole版本:5.0.0

Activity

  1. limingxinleo commented on Apr 20, 2026

    @limingxinleo
    Member
    <?php
    
    namespace App;
    
    use Hyperf\Cache\Annotation\Cacheable;
    use Hyperf\Cache\Annotation\CacheEvict;
    
    class FooService
    {
        #[Cacheable(prefix: 'test', value: '_#{id}')]
        public function put(string $id)
        {
            return uniqid();
        }
    
        #[CacheEvict(prefix: 'test', value: '_#{id}')]
        public function delete(string $id)
        {
            return uniqid();
        }
    }

    经测试没有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions