public function delete($key) { $this->memcachedObj->delete($key); $resultCode = $this->memcachedObj->getResultCode(); if ($resultCode != \Memcached::RES_SUCCESS && $resultCode != \Memcached::RES_NOTFOUND) { throw new StorageException('[STORAGE] "' . $this->getStorageName() . '::delete" failed for key "' . $key . '"!' . ' StorageRespCode: ' . $resultCode); } unset($this->casArray[$key]); return $resultCode; }
public function testDelete() { $this->storage->get('oldkey'); $this->assertArrayHasKey('oldkey', $this->storage->getCasArray(), 'Cas array has not key "oldkey"!'); $this->assertEquals(0, $this->storage->delete('oldkey'), 'Delete failed!'); $this->assertArrayNotHasKey('oldkey', $this->storage->getCasArray(), 'Cas array has key "oldkey"!'); try { self::$memcached->resetServerList(); $this->storage->delete('oldkey'); } catch (StorageException $e) { if (count(self::$memcached->getServerList()) == 0) { self::$memcached->addServers(array(array(MEMCACHED_HOST, MEMCACHED_PORT))); } return; } $this->fail('Storage delete exception test failed'); }