public function __construct() { $this->bucket = Conf::fromCache('OSS_BUCKET') ? Conf::fromCache('OSS_BUCKET') : ''; $this->domain = Conf::fromCache('OSS_ACCESS_URI') ? Conf::fromCache('OSS_ACCESS_URI') : ''; //拼接文件返回地址的 http host部分 $hostname = Conf::fromCache('OSS_HOST') ? Conf::fromCache('OSS_HOST') : ''; //定义操作的指定节点hostname $OSS_ACCESS_ID = Conf::fromCache('OSS_ACCESS_KEY_ID') ? Conf::fromCache('OSS_ACCESS_KEY_ID') : ''; $OSS_ACCESS_KEY = Conf::fromCache('OSS_ACCESS_KEY_SECRET') ? Conf::fromCache('OSS_ACCESS_KEY_SECRET') : ''; $this->oss = new \ALIOSS($OSS_ACCESS_ID, $OSS_ACCESS_KEY, $hostname); }
/** * 初始化参数 * @example * new \yunke\upload\Oss('sales'); * @param array|string $config */ public function init() { parent::init(); $this->bucket = Conf::fromCache('OSS_BUCKET') ? Conf::fromCache('OSS_BUCKET') : ''; $this->domain = Conf::fromCache('OSS_ACCESS_URI') ? Conf::fromCache('OSS_ACCESS_URI') : ''; //拼接文件返回地址的 http host部分 $hostname = Conf::fromCache('OSS_HOST') ? Conf::fromCache('OSS_HOST') : ''; //定义操作的指定节点hostname $OSS_ACCESS_ID = Conf::fromCache('OSS_ACCESS_KEY_ID') ? Conf::fromCache('OSS_ACCESS_KEY_ID') : ''; $OSS_ACCESS_KEY = Conf::fromCache('OSS_ACCESS_KEY_SECRET') ? Conf::fromCache('OSS_ACCESS_KEY_SECRET') : ''; if ($this->rootDirName) { $this->root = $this->rootDirName; } $this->oss = new \ALIOSS($OSS_ACCESS_ID, $OSS_ACCESS_KEY, $hostname); }
/** * Returns the underlying memcached object. * @return \Memcached the memcached object used by this cache component. * @throws InvalidConfigException if memcached extension is not loaded */ public function getMemcached() { if ($this->_cache === null) { if (!extension_loaded('memcached')) { throw new InvalidConfigException("MemCache requires PHP extension to be loaded."); } $global = \yunke\helpers\Conf::fromLocal(); //获取配置 $this->options = array('host' => $global['OCS_HOST'] ? $global['OCS_HOST'] : '127.0.0.1', 'port' => $global['OCS_PORT'] ? $global['OCS_PORT'] : 11211, 'user' => $global['OCS_SASL_USER'] ? $global['OCS_SASL_USER'] : '', 'passwd' => $global['OCS_SASL_PWD'] ? $global['OCS_SASL_PWD'] : ''); $this->_cache = $this->persistentId !== null ? new \Memcached($this->persistentId) : new \Memcached(); $this->_cache->setOption(\Memcached::OPT_COMPRESSION, false); $this->_cache->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); $this->_cache->addServer($this->options['host'], $this->options['port']); /* if ( !empty($this->options['user']) && !empty($this->options['passwd']) ) { $this->_cache->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); $this->_cache->setSaslAuthData($this->options['user'], $this->options['passwd']); } */ } return $this->_cache; }