Phalcon\Cache\Backend\Aerospike::queryKeys PHP Метод

queryKeys() публичный Метод

public queryKeys ( string $prefix = null ) : array
$prefix string
Результат array
    public function queryKeys($prefix = null)
    {
        if (!$prefix) {
            $prefix = $this->_prefix;
        } else {
            $prefix = $this->getPrefixedIdentifier($prefix);
        }
        $keys = [];
        $globalPrefix = $this->_prefix;
        $this->db->scan($this->namespace, $this->set, function ($record) use(&$keys, $prefix, $globalPrefix) {
            $key = $record['key']['key'];
            if (empty($prefix) || 0 === strpos($key, $prefix)) {
                $keys[] = preg_replace(sprintf('#^%s(.+)#u', preg_quote($globalPrefix)), '$1', $key);
            }
        });
        return $keys;
    }

Usage Example

Пример #1
0
 public function testShouldUseOutputFrontend()
 {
     $time = date('H:i:s');
     $frontCache = new CacheOutput(['lifetime' => 10]);
     $cache = new CacheAerospike($frontCache, $this->getConfig());
     ob_start();
     $content = $cache->start('test-output');
     $this->keys[] = 'test-output';
     $this->assertNull($content);
     echo $time;
     $obContent = ob_get_contents();
     $cache->save(null, null, null, true);
     ob_end_clean();
     $this->assertEquals($time, $obContent);
     $this->assertEquals($time, $cache->get('test-output'));
     $content = $cache->start('test-output');
     $this->assertEquals($content, $obContent);
     $this->assertEquals($content, $cache->get('test-output'));
     $keys = $cache->queryKeys();
     $this->assertEquals([0 => 'test-output'], $keys);
 }