/** * Stores a context. * * This method stores the context that it received to the backend specified * storage place. * * @throws ezcTranslationWriterNotInitializedException when the writer is * not initialized with initWriter(). * @param string $context The context's name * @param array(ezcTranslationData) $data The context's translation map * @return void */ public function storeContext($context, array $data) { if (is_null($this->writeLocale)) { throw new ezcTranslationWriterNotInitializedException(); } foreach ($data as $key => $cachedElement) { if ($cachedElement->status == ezcTranslationData::OBSOLETE) { unset($data[$key]); } } $cachedContext = $this->cache->store("{$this->writeLocale}/{$context}", $data); }
public function testRestoreWithoutSearch() { $cache = new ezcCacheStorageFileArray($this->createTempDir('ezcCacheStorageFileTest'), array('extension' => '.c', 'ttl' => false)); $id = "test"; $keys = array(10000, 1, 10, 100, 1000); // Store foreach ($keys as $key) { // No cache may exist! $this->assertFalse($cache->restore($id, array(0 => $key, 1 => "en"), false)); $cache->store($id, "ID={$key}&LANG=en", array(0 => $key, 1 => "en")); } // Restore foreach ($keys as $key) { $this->assertEquals($cache->restore($id, array(0 => $key, 1 => "en"), false), "ID={$key}&LANG=en"); } $this->removeTempDir(); }