Skip to content

\Phalcon\Cache\Backend\File -> queryKeys #14190

Closed
@Mexthey

Description

@Mexthey

Hello, strictly speaking, I don't know if this is a bug, because It's easy to fix, is it designed to be like this originally?

minimal script to reproduce the issue

    public function reproduceAction()
    {
        $cache = new \Phalcon\Cache\Backend\File(
            new \Phalcon\Cache\Frontend\Data([
                "lifetime" => $this->config->cache->lifetime,
            ]), [
                "prefix" => $this->config->cache->prefix,
                "cacheDir" => $this->config->cache->dir,
            ]
        );

        $prefix = 'my-prefix';
        foreach (range('a', 'z') as $key => $value) {
            $key = $prefix . '.' . $key;
            $cache->save($key, $value);
        }

        $allKeys = $cache->queryKeys($prefix);
        print_r($allKeys);

        $fail = 0;
        if ($allKeys) {
            foreach ($allKeys as $delKey) {
                // If {$this->config->cache->prefix } is not empty 
               // It does't work,because the result of queryKeys is contained prefix
                $cache->delete($delKey) || $fail++;
            }
        }
        print_r($fail);
        exit;
    }

Details

  • Phalcon version: (php --ri phalcon) v3.4.3
  • PHP Version: (php -v) PHP 7.2.17 x64 TS
  • Operating System: win
  • Installation type: download dll
  • Zephir version (if any):
  • Server: Nginx
  • Other related info (Database, table schema): Postgresql

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions