Stash\Item::setKey PHP Method

setKey() public method

public setKey ( array $key, $namespace = null )
$key array
    public function setKey(array $key, $namespace = null)
    {
        $this->namespace = $namespace;
        $keyStringTmp = $key;
        if (isset($this->namespace)) {
            array_shift($keyStringTmp);
        }
        $this->keyString = implode('/', $keyStringTmp);
        // We implant the namespace "cache" to the front of every stash object's key. This allows us to segment
        // off the user data, and use other 'namespaces' for internal purposes.
        array_unshift($key, 'cache');
        $this->key = array_map('strtolower', $key);
    }

Usage Example

 public function testConstructionOptions()
 {
     $key = array('apple', 'sauce');
     $options = array();
     $options['servers'][] = array('127.0.0.1', '11211', '50');
     $options['servers'][] = array('127.0.0.1', '11211');
     $options['extension'] = $this->extension;
     $driver = new Memcache();
     $driver->setOptions($options);
     $item = new Item();
     $poolStub = new PoolGetDriverStub();
     $poolStub->setDriver($driver);
     $item->setPool($poolStub);
     $item->setKey($key);
     $this->assertTrue($item->set($key), 'Able to load and store memcache driver using multiple servers');
     $options = array();
     $options['extension'] = $this->extension;
     $driver = new Memcache();
     $driver->setOptions($options);
     $item = new Item();
     $poolStub = new PoolGetDriverStub();
     $poolStub->setDriver($driver);
     $item->setPool($poolStub);
     $item->setKey($key);
     $this->assertTrue($item->set($key), 'Able to load and store memcache driver using default server');
 }
All Usage Examples Of Stash\Item::setKey