function csvDataToMemcache($csvList, $csvDir, $memIP, $memPort) { $memcached = new Memcache(); $memcached->connect($memIP, $memPort); foreach ($csvList as $key => $value) { $csvObj = new parseCSV(); $csvObj->auto($csvDir . '/' . $value); list($fileName, $fileType) = explode('.', $value); $memcached->set($fileName, $csvObj->data, MEMCACHE_COMPRESSED, 0); //debug info //echo "<br/>--------------------------------------------$fileName.csv to memcache-------------------------------------------<br/>"; print_r($memcached->get($fileName)); } $memcached->close(); echo "success"; }
/** * Close the backend * * @return boolean */ public function close() { if (is_object($this->_backend)) { return $this->_backend->close(); } return false; }
public function __destruct() { if ($this->instance) { $this->instance->close(); unset($this->instance); } }
public function close() { $this->gc(ini_get('session.gc_maxlifetime')); $this->handle->close(); $this->handle = null; return true; }
/** * {@inheritDoc} * @see \Mcustiel\SimpleCache\Interfaces\CacheInterface::finish() */ public function finish() { if ($this->connection !== null) { $this->connection->close(); $this->connection = null; } }
function disconnect() { if ($this->connected) { $this->connected = false; return $this->cache->close(); } return true; }
/** * Disconnect the open connection * * @return static * * @throws ConnectionException */ public function disconnect() { if ($this->_connection !== null) { $this->_connection->close(); } $this->_connection = null; return $this; }
public function __destruct() { if (isset($this->memcache)) { $this->memcache->close(); $this->memcache = NULL; } parent::__destruct(); }
public function __destruct() { if ($this->alive) { try { $this->instance->close(); } catch (BaseException $e) { // shhhh. } } }
/** * Destructor * * @return void */ public function __destruct() { if ($this->_cache instanceof \Memcache) { $this->_cache->close(); } if (is_resource($this->_socket)) { $cmd = 'quit' . self::EOL; fwrite($this->_socket, $cmd); fclose($this->_socket); } }
public function _after(TestCase $test) { $this->memcache->flush(); switch (get_class($this->memcache)) { case 'Memcache': $this->memcache->close(); break; case 'Memcached': $this->memcache->quit(); break; } }
public static function close() { //already Closed Resource if (!self::$_Connection instanceof Memcache) { return; } self::$_Connection->close(); foreach (self::$_MemCachePool as $key => $_host) { unset(self::$_MemCachePool[$key]); } self::$_Connection = null; self::$_INSTANCE = null; }
public function _before(\Codeception\TestCase $test) { if (class_exists('\\Memcache')) { $this->memcache = new \Memcache(); $this->memcache->close(); $this->memcache->connect($this->config['host'], $this->config['port']); } elseif (class_exists('\\Memcached')) { $this->memcache = new \Memcached(); $this->memcache->addServer($this->config['host'], $this->config['port']); } else { throw new \Codeception\Exception\ModuleConfig(__CLASS__, 'Memcache classes not loaded'); } }
/** * Close connection to memcache server * * @return bool */ protected function close() { if (!$this->is_connected) { return false; } return $this->memcache->close(); }
function getStatsFromCache($type = 'sizes', $slabib = null, $limit = 100) { $ini = parse_ini_file('scielo.def', true); $memcache = new Memcache(); $memcache->connect($ini['CACHE']['SERVER_CACHE'], $ini['CACHE']['SERVER_PORT_CACHE']); if ($slabib != null) { $arr = $memcache->getExtendedStats($type, $slabid, $limit); } else { $arr = $memcache->getExtendedStats($type); } $saida = ''; $arr = array_pop($arr); $saida .= '<table border="1">'; foreach ($arr as $key => $value) { $saida .= '<tr>'; $saida .= '<td>' . $key . '</td>'; if (is_array($value)) { $saida .= '<td><table border="1">'; foreach ($value as $k => $v) { $saida .= '<tr>'; $saida .= '<td>' . $k . '</td>'; $saida .= '<td>' . $v . '</td>'; $saida .= '</tr>'; } $saida .= '</table></td>'; } else { $saida .= '<td>' . $value . '</td>'; } $saida .= '</tr>'; } $saida .= '</table>'; $memcache->close(); return $saida; }
/** * 关闭 * @see Cache#_disConnect() */ protected function close() { if ($this->_memcache) { $this->_memcache->close(); $this->_memcache = null; } }
function checkCache($check = 0, $in, $out, $set = 0) { $inOut = 'inOut_' . $in . '_' . $out; $memcache_obj = new Memcache(); $memcache_obj->connect('127.0.0.1', 11211) or die("Could not connect"); if ($check === 1) { $available = $memcache_obj->get($inOut); if (!$available) { $set = $this->superfastCheck(1, $in, $out); $memcache_obj->set($inOut, $set, false, 324); $available = $memcache_obj->get($inOut); } } elseif ($check === 2) { $memcache_obj->flush(); } else { $set = $this->superfastCheck($in, $out); //var_dump($set); $memcache_obj->set($inOut, $set, false, 324); //echo $inOut; $available = $memcache_obj->get($inOut); //var_dump($memcache_obj->getStats()); } //var_dump($available); $memcache_obj->close(); return $available; }
public function n() { $mec = new Memcache(); $mec->connect('127.0.0.1', 11211); $mec->set('push_58609', array('message' => 'hello'), MEMCACHE_COMPRESSED, 30); $mec->close(); }
/** * Disconnect from Memcache */ public function disconnect() { if ($this->connected) { $this->memcache->close(); } $this->connected = false; }
/** * Closing cache * * @since 1.0.0 * @author Dennis Eichhorn <*****@*****.**> */ public function close() { if ($this->memc !== null) { $this->memc->close(); $this->memc = null; } }
/** * Close connection to Memcache. * * @return void */ public function __destruct() { if ($this->_memcache !== null) { $this->_memcache->close(); unset($this->_memcache); } return; }
function save_to_cache($key, $res) { $m = new Memcache(); $m->connect(getenv("CACHE2_HOST"), getenv("CACHE2_PORT")); $op = $m->set($key, $res); $m->close(); return $op; }
/** * Closes this memcache connection * * @return \r8\Cache\Memcache Returns a self reference */ function disconnect() { // Only close the connection if it is open if ($this->isConnected()) { $this->link->close(); $this->link = null; } return $this; }
function save_to_cache($key, $res) { $m = new Memcache(); $m->connect('tunnel.pagodabox.com', 11211); if ($_SERVER['COMPRESS_CACHE'] === true) { $op = $m->set($key, $res, MEMCACHE_COMPRESSED); } else { $op = $m->set($key, $res); } $m->close(); return $op; }
function update_lang_file() { global $modx; $strings = $modx->db->query("select * from `modx_a_lang` order by lang_id asc"); $mem = new Memcache(); $mem->connect('127.0.0.1', 11211); $mem->flush(); while ($t = $modx->db->getRow($strings)) { $r = $t; unset($r['lang_id']); $mem->set($modx->config['site_name'] . '_' . $t['lang_id'], $r); } $mem->close(); }
/** * {@inheritDoc} */ protected function check() { if (!$this->getContainer()->hasParameter('memcache_servers')) { return false; } $connections = $this->getContainer()->getParameter('memcache_servers'); foreach ($connections as $key => $connection) { $memcache = new \Memcache(); if (!$memcache->connect($connection['host'], $connection['port'])) { return false; } $memcache->close(); } return true; }
protected function setUp() { if (!ezcBaseFeatures::hasExtensionSupport('memcache')) { $this->markTestSkipped('PHP must have Memcache support.'); } if (!ezcBaseFeatures::hasExtensionSupport('zlib')) { $this->markTestSkipped('PHP must be compiled with --with-zlib.'); } $testMemcache = new Memcache(); if (@$testMemcache->connect('localhost', 11211) === false) { $this->markTestSkipped('No Memcache server running on port 11211 found.'); } $testMemcache->close(); $this->memcacheBackend = new ezcCacheMemcacheBackend(); }
/** * Performs the test. * * @return \Jyxo\Beholder\Result */ public function run() { // The memcache extension is required if (!extension_loaded('memcache')) { return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::NOT_APPLICABLE, 'Extension memcache missing'); } $random = md5(uniqid(time(), true)); $key = 'beholder-' . $random; $value = $random; // Status label $description = gethostbyaddr($this->ip) . ':' . $this->port; // Connection (@ due to notice) $memcache = new \Memcache(); if (false === @$memcache->connect($this->ip, $this->port)) { return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Connection error %s', $description)); } // Saving if (false === $memcache->set($key, $value)) { $memcache->close(); return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Write error %s', $description)); } // Check $check = $memcache->get($key); if (false === $check || $check !== $value) { $memcache->close(); return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Read error %s', $description)); } // Deleting if (false === $memcache->delete($key)) { $memcache->close(); return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Delete error %s', $description)); } $memcache->close(); // OK return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::SUCCESS, $description); }
/** * 微信access_token获取 getAccessToken 有缓存设置 * @param string $appid * @param string $appsecret * @param string $memName * @return access_token */ public static function getAccessToken($appid, $appsecret, $memName) { //设置缓存,100分钟更新一次access_token $mem = new Memcache(); $mem->connect('localhost', 11211) or die('Could not connect'); $access_token = $mem->get($memName); if (empty($access_token)) { $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $appsecret; $res = self::http_request($url); $result = json_decode($res, true); $access_token = $result['access_token']; $mem->set($memName, $access_token, 0, 6000); } $mem->close(); return $access_token; }
protected function storeMemcache($title, $data) { $check = $this->memcache->connect(); if ($check == 3) { // Connection failed trigger_error('Unable to connect to memcache server', E_USER_ERROR); } $ptitle = $this->prefix . $title; if ($this->memcache_set) { $this->memcache->set($ptitle, $data); } else { $this->memcache->add($ptitle, $data); } // if we caused the connection above, then close it if ($check == 1) { $this->memcache->close(); } }