lithium\storage\cache\adapter\XCache::read PHP Метод

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

Note that this is not an atomic operation when using multiple keys.
public read ( array $keys ) : array
$keys array Keys to uniquely identify the cached items.
Результат array Cached values keyed by cache keys on successful read, keys which could not be read will not be included in the results array.
    public function read(array $keys)
    {
        if ($this->_config['scope']) {
            $keys = $this->_addScopePrefix($this->_config['scope'], $keys);
        }
        $results = array();
        foreach ($keys as $key) {
            $result = xcache_get($key);
            if ($result === null && !xcache_isset($key)) {
                continue;
            }
            $results[$key] = $result;
        }
        if ($this->_config['scope']) {
            $results = $this->_removeScopePrefix($this->_config['scope'], $results);
        }
        return $results;
    }

Usage Example

Пример #1
0
 public function testReadWithScope()
 {
     $adapter = new XCache(array('scope' => 'primary'));
     xcache_set('primary:key1', 'test1', 60);
     xcache_set('key1', 'test2', 60);
     $keys = array('key1');
     $expected = array('key1' => 'test1');
     $result = $adapter->read($keys);
     $this->assertEqual($expected, $result);
 }