使用memcache订阅源
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用memcache订阅源相关的知识,希望对你有一定的参考价值。
feed class with baseUrl and endpoint curling the target and caching on memcache
<?php class Feed { private $_content; private $_defaultHost = 'local'; private $_baseUrl = 'http://noticias.mtvla.com/feeds/'; private $_endpoint; private $_memcache; 'host' => 'localhost', 'port' => '11211' ), 'host' => 'international-memcache-001.1515.mtvi.com', 'port' => '11211' ), 'host' => 'international-memcache-002.1515.mtvi.com', 'port' => '11211' ), 'host' => 'international-memcache-005.811.mtvi.com', 'port' => '11211' ) ) ); public function __construct() { $this->_setInstance() ->_memcacheConnect(); } public function getLastArticles() { return $this->setEndpoint('latest-articles-paginated?page=1') ->_doRequest() ->_sendResponse(); } public function setEndpoint($endpoint) { $this->_endpoint = $endpoint; return $this; } public function getEndpoint() { return $this->_endpoint; } private function _sendResponse() { } private function _doRequest() { $uri = $this->_baseUrl . $this->_endpoint; $this->_content = $this->_memcache->get($uri); if ($this->_content == false) { $this->_memcache->set($this->_endpoint, $this->_content); } return $this; } private function _setInstance() { $this->_host = $this->_defaultHost; // localhost $this->_host = "dev"; $this->_host = "qa"; $this->_host = "live"; return $this; } private function _memcacheConnect() { $this->_memcache = new Memcache; $this->_memcache->connect( $this->_settings['memcache'][$this->_host]['host'], $this->_settings['memcache'][$this->_host]['port'] return $this; } } $feed = new Feed();
以上是关于使用memcache订阅源的主要内容,如果未能解决你的问题,请参考以下文章
c_cpp UV Index Indicator订阅PubNub并使用颜色显示UV索引值。博文的代码片段。在这里查看项目:https:/
如何取消订阅RxKotlin / RxJava中的Flowable?
javascript UV Index Monitor App订阅PubNub并显示UV索引值。博文的代码片段。在这里查看项目:https:// githu